Glossary

What is text-to-SQL?

Text-to-SQL is an AI approach that converts natural language questions into SQL database queries. You ask "How many active customers do we have?" and the AI generates the SQL to answer it. The appeal is obvious: anyone can query a database without knowing SQL.

The challenge is equally obvious. The AI has to guess which tables to query, how to join them, and what "active customer" means in your specific database. Get any of these wrong and the answer looks right but is not.

How text-to-SQL works

A large language model receives your question along with a description of the database schema (table names, column names, relationships). It uses this context to generate a SQL query that should answer your question. The query runs against the database and returns results.

This works well for simple questions against simple schemas. "Show me all orders from last month" on a database with a single orders table is straightforward. The difficulty scales with complexity: many tables, implicit joins, business-specific definitions, and access control requirements. For a deeper look at why this matters, read why AI gets enterprise data wrong.

Where text-to-SQL excels and struggles

An honest look at the approach, not a dismissal.

Where it works well

  • Simple schemas with clear table and column names
  • Ad-hoc exploration and data discovery
  • Questions that map to a single table or simple join
  • Environments where approximate answers are acceptable

Where it struggles

  • Complex schemas with hundreds of tables
  • Business-specific definitions the AI has not seen
  • Multi-step queries requiring specific join logic
  • Situations requiring access control or audit trails
  • Business-critical data where accuracy must be 100%

The alternative: template-based data access

Template-based data access takes a different approach. Instead of having AI generate queries, business logic is captured once in predefined templates by people who know the data. AI then selects and calls the right template rather than generating SQL.

This is the approach dhino uses. The AI understands the question (non-deterministic). dhino executes the predefined logic to get the answer (deterministic execution). The result is accurate, governed, and auditable, because the query logic was written and tested by experts, not generated on the fly.

Neither approach is universally better. Text-to-SQL excels at ad-hoc exploration. Template-based access excels at business-critical operations. Many enterprises will use both, for different purposes. Read the full comparison.

See how dhino Trust uses template-based access for governed Copilot data queries.

Want accurate AI data access without text-to-SQL risks?

See how dhino combines AI understanding with deterministic execution for trusted enterprise data answers.