Skip to content

Helping agents understand enterprise SQL: from a business question to the right data relationships

Using “how many customers are in each region” as an example, we show how Studio combines a data map with hybrid retrieval, validated on a synthetic ERP.

Explore UnieAI Studio
薄荷綠色資料層之間,藍色線條相互連接

A user asks “how many customers are in each region,” but the database may only have abbreviations like cst, cty and rgn. Before answering, the agent needs to know which tables represent customers, countries and regions, and how they should be joined.

UnieAI Studio's data map links the schema with semantic descriptions, helping the agent locate data from business terms and then query along relationships. This post separates retrieval, relationship understanding and answer verification, and explains what each solves.

First map business terms back to data

Column names often keep only the abbreviations chosen at design time. If a query only matches the words in the question, it may miss the tables it actually needs. The data map keeps tables, columns and foreign keys, and adds human-readable semantic descriptions so that “customer” maps to cst.

In this example, cst holds customers, cty maps to countries and rgn to regions. Once the meaning of the three tables is known, the agent still has to confirm how customers link to countries and how countries link to regions.

How it works

Hybrid retrieval considers both lexical and semantic similarity to fetch candidate tables; the data map then supplies columns and relationships for the agent to plan the query. The query result is then turned into an answer the user can understand.

  1. Locate data: map “customer” and “region” in the question to the relevant tables.
  2. Confirm relationships: follow cst → cty → rgn and check the available join columns and direction.
  3. Build the query: count customers grouped by region and check what is included.
  4. Return the answer: present the numbers together with the data sources and counting definition used.

How to prepare your first set of questions

Start with operational questions your team already knows the right answer to; that makes it easier to confirm the data and definitions line up. For example, “how many active customers are in each region” requires agreeing in advance on the definition of an active customer, the reporting date, and whether to exclude test data.

  • Document the business meaning of tables and key columns, especially abbreviations and similar concepts.
  • Confirm cross-table relationships and note statuses, dates and duplicates that affect the counts.
  • Keep a manual query or existing report for each question as the reference to compare answers against.

Retrieval evaluation: did it find the needed tables?

The BenchBroad synthetic ERP contains 400 tables, 5,720 columns and 781 foreign-key relationships. On 52 Chinese gold-table questions, lexical retrieval reached a Recall@8 of 46%; hybrid lexical-and-semantic retrieval reached 100% (52/52).

Recall@8 measures whether the top 8 retrieval results cover the labeled target tables. It is a good check that the agent gets the right starting point for its query. The data size is that of this synthetic test set.

Recall@8 / %

SQL table retrieval: Recall@8

BenchBroad synthetic ERP, 52 Chinese gold-table questions. Table retrieval Recall@8; hybrid search retrieved 52/52. This measures table retrieval.

From finding the data to a verified answer

A separate agent test used 60 questions in two languages, three rounds each — 360 runs in total — and scored 95% against internal answer criteria. This is a different level of measurement from the table retrieval above.

The report is dated August 30, 2026 and used Qwen3.6-35B-A3B and Qwen3-Embedding-8B. These answer criteria did not verify full SQL result-set equivalence question by question; when adopting it, you can add result-set and edge-case comparisons from your own business so acceptance stays closer to real work.

Bring the tests back into everyday queries

Build a small set of questions you'll reuse: a few each for single-table counts, cross-table statistics, date ranges and easily confused terms. Rerun them after data or model updates and look separately at candidate tables, join relationships and final answers — you'll know which layer an improvement should land in.

FAQ

Is 400 tables the product's capacity limit?

That is the size of the BenchBroad synthetic ERP test. Planning for a production workspace depends on your data sources, query needs and deployment environment.

Does successful retrieval mean the SQL is always correct?

Retrieval is the starting point. You still need to check the joins, filters, grouping definitions and actual results to confirm the answer matches the business definition.

Keep exploring