0Pricing
AI Agents · Lesson

Handling Ambiguous Database Questions

Clarifying questions, schema disambiguation, and multi-table join reasoning.

The Ambiguity Problem in NL-to-SQL

Natural language is inherently ambiguous. When someone asks "Show me recent orders", a human asks: recent for who? in what time frame? sorted how?

An agent that silently assumes defaults will produce results the user didn't expect. A good agent detects ambiguity and asks targeted clarifying questions.

Types of Ambiguity

There are four common categories of ambiguous questions in database contexts:

  • Temporal ambiguity: 'recent', 'latest', 'old', 'this year'
  • Scope ambiguity: 'top customers' — top by what metric?
  • Table ambiguity: multiple tables could answer the question
  • Filter ambiguity: 'active users' — what defines active?
# Examples of each type
ambiguous_examples = {
    'temporal': 'Show me recent orders',         # last 7 days? 30 days? 1 year?
    'scope':    'Who are the top customers?',     # by revenue, order count, or recency?
    'table':    'Show me user activity',          # from users, sessions, or audit_log?
    'filter':   'List all active products'        # active = in_stock? not discontinued?
}

All lessons in this course

  1. How NL-to-SQL Agents Work
  2. Schema Understanding and Injection
  3. Generating and Validating SQL Queries
  4. Handling Ambiguous Database Questions
← Back to AI Agents