Text to sql works without database documentation using query logs
Schema-Free Text-to-SQL: Learning Enterprise Database Structure from Query Logs
Computation and Language
Summary
Making computers understand questions about databases usually needs detailed info about the database’s structure. This is often missing or unclear in real business settings. The authors created a way for computers to learn how databases are organized simply by looking at past questions people asked the database. Their method builds a network of how tables and columns connect, using this to better answer new questions. This approach works much better than older methods when tested on real business databases and expert feedback.
What this means in practice
- •For enterprise software engineers: Build natural language interfaces for internal databases without relying on full schema documentation.
- •For business intelligence teams: Improve accuracy of SQL queries generated from user questions by learning database structure from historical queries.
Authors
Ömer Faruk Akgül, Nikhil Kapahi, Prajit Reddy Muppidi
Abstract
Text-to-SQL systems achieve remarkable accuracy on academic benchmarks, yet performance drops dramatically in enterprise deployments. This gap stems from a fundamental assumption: existing approaches require complete schema documentation, but enterprise databases typically lack comprehensive documentation, featuring cryptic naming and implicit relationships. We present the first text-to-SQL framework that operates without schema documentation, instead learning database structure from historical query logs. Query logs encode implicit structural knowledge: which tables are queried together, how they join, and what columns map to business concepts. We construct a knowledge graph from parsed query patterns and introduce entity-driven GraphRAG retrieval that grounds user questions in domain terminology rather than relying solely on embedding similarity. Validated on both an industrial deployment with expert evaluation and the Beaver benchmark, our approach substantially outperforms similarity-based retrieval methods, the dominant industry approach, in both executability and answer quality. On Beaver, we achieve 95.7% execution validity compared to 60.8% for embedding-based retrieval, with expert data engineers preferring our system 70% to 10% on internal deployment. Our work demonstrates that text-to-SQL can operate effectively in schema-ambiguous enterprise environments, enabling natural language database interfaces "in the wild".