How does iDBQuery know how to join two tables together?

iDBQuery infers joins by reading your schema — primary and foreign keys, matching column names and data types — plus its semantic layer, then writes SQL that links the right tables on the right keys. It shows the join it used and cites every figure back to its source rows.

When you ask a question that spans more than one table, iDBQuery works out the relationship for you instead of asking you to model it.

  • Schema signals. During onboarding it introspects the database and records primary keys, declared foreign keys, column names, and data types. A `customer_id` in an orders table that matches the primary key of a customers table is a strong join candidate.
  • Semantic layer. Where keys are missing or names are cryptic, the semantic layer supplies learned relationships and business meaning so the AI still links the right entities.
  • Generated SQL. iDBQuery writes the actual `JOIN` clause, runs it against the live data, and returns the number, table, or chart.

For example, ask "total revenue by sales rep last quarter" across `orders`, `line_items`, and `reps` and iDBQuery joins order to line item on the order key and order to rep on the rep key, aggregates, and answers. Because it shows the SQL and cites each figure back to the exact rows, you can confirm it joined on the columns you expected. If a relationship is genuinely ambiguous it asks rather than guessing.

Updated 2026-06-22