NL2SQL: business rules, table relationships, and standard Q&A¶
These settings define business interpretation, data joins, and queries for common questions. Find them in Semantic configuration → NL2SQL semantics.
Business rules¶
Create a rule, enter its identifier, select one or more associated tables, and save a natural-language explanation.
State conditions and exceptions. For example: “For an opening balance, use the previous year’s closing balance unless the user explicitly specifies another period.” Use mandatory constraints for filters that must be added to SQL.
Test both a matching question and an exception after saving to check the rule’s scope.
Table relationships¶
Define the direction, type, and fields of a join so the agent does not infer it from similar column names.
Create a relationship and enter its identifier and description.
Select left and right tables.
Choose the JOIN type, such as LEFT JOIN or INNER JOIN.
Add a left field, comparison, and right field for each join condition.
Inspect direction and condition grouping in the JOIN SQL preview, then save.
For orders joined to customers by customer ID, choose a join consistent with whether unmatched orders must be retained. Test unmatched rows, duplicate keys, and result counts. Executable joins can still duplicate aggregated amounts.
Standard Q&A¶
Structured standard Q&A stores a standard question and business-approved SQL. RAG standard Q&A instead stores text answers.
Create an entry with an identifier and scenario description.
Enter the standard question and equivalent questions with the same business object and key conditions.
Choose reference or mandatory use.
Enter the approved complete read-only SQL, pass validation, and save.
Test the standard wording, equivalent wording, and a question with different conditions.
Mode |
Meaning |
|---|---|
Reference |
Use as a reference for answers and SQL generation alongside other semantics |
Mandatory |
The configured SQL can be used when intent, business object, and key filters match |
SQL must be a single read-only SELECT or WITH query. Writes, schema changes, and multiple statements are not supported. After syntax validation, verify source tables, filters, and returned data.
Do not treat this month’s and last month’s revenue as equivalent questions for one fixed query unless its logic explicitly supports and correctly handles the period difference.