The problem
A user can ask a simple question, but the underlying database may contain many tables, ambiguous business terms and complicated joins. A naive single-prompt text-to-SQL implementation is hard to trust and expensive to repeat.
The POC needed to demonstrate a useful conversational interface while maintaining control over database access, limiting generated queries and providing evidence of what was actually executed.
What I led and built
I led the client POC, setting the architecture and building its initial implementation with n8n and Flowise. The approach separated schema discovery from the conversational request path.
- Designed discovery of database relationships and semantic descriptions so the model didn't need to infer the whole schema every turn.
- Split reasoning into intent, relevant table/column selection and SQL planning, with a later design consolidation to reduce model calls.
- Used conversational context to support follow-up questions and refinement.
- Made SQL and results inspectable rather than presenting an untraceable model answer.
Key engineering decisions
Make generated SQL a proposal, not authority
Language models help determine what data is relevant, but a deterministic layer must validate and execute a restricted query. Read-only permissions, timeouts and row limits are more credible controls than asking the model to “be careful.”
Use structured results for the interface
A good experience includes tables, charts, context-aware follow-ups and the executed query. Rendering should be based on verified database rows, not invented chart values.
Outcome and current scope
The documented later POC iteration tested nine demonstration scenarios, including multi-turn follow-ups, charts, an ambiguous request and refusal of destructive SQL. The records describe comparison with independently written SQL and 24 focused tests.
Evidence and context
Architecture and walkthrough notes are available for discussion, along with example test cases and the logic behind the SQL safety boundaries. The POC's internal implementation is not published as a public product.