Teaching SQL with an Agentic LLM: A Fifteen-Category Hallucination Taxonomy and Mitigation Strategy, Illustrated with Claude Sonnet 5
Paolino Di Felice
Key points
From the paper's conclusion- Its core is a taxonomy of fifteen hallucination categories that is coarse enough to serve as a classroom checklist, identified through an expert-driven process (the text-to-SQL literature and 27 years of teaching experience) and illustrated on a five-table PostgreSQL schema through constructed baseline outputs that the instructor can use to open a classroom discussion of each failure.
Abstract
Students increasingly use large language models (LLMs) to translate natural-language requests into SQL, yet these models hallucinate: they return queries, numbers, explanations or assurances unsupported by the schema, data, or request, often in a form that executes without error. This paper proposes a teaching instrument for a first course on relational databases, designed to let students experience, recognize and prevent such failures; its contribution is conceptual and illustrative. This paper proposes a teaching instrument for a first course on relational databases that lets students experience, recognize, and prevent such failures. Its core is a taxonomy of fifteen hallucination categories that is coarse enough to serve as a classroom checklist, identified through an expert-driven process (the text-to-SQL literature and 27 years of teaching experience) and illustrated on a five-table PostgreSQL schema through constructed baseline outputs that the instructor can use to open a classroom discussion of each failure. Each category is paired with a two-layer mitigation: a context pack of standing rules and seven reference files, stored once in a Claude Project, and an agentic execute–observe–correct loop in which the assistant runs rule-prescribed checks against a live database before answering. Each countermeasure is assigned to the instructor, the loop, or the user. Nine categories have a counterpart in prior text-to-SQL taxonomies, two lack a dedicated one, and four concern the answer returned to the user rather than the query, thereby escaping static benchmark-based evaluation. The workflow is free for students. The effectiveness and generalizability of the mitigation have not yet been systematically validated; frequency and classroom effectiveness are left to future work.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Text-to-SQL in the Era of Large Language Models: A Survey of Reasoning-Centric and Efficiency-Centric ApproachesElectronics · 2026
- SchemaRAG: A Schema-aware Retrieval-Augmented Generation Framework for Text-to-SQLProceedings of the ACM on Management of Data · 2026
- Reimagining Text-to-SQL: A Survey of Large Language Model Architectures and StrategiesarXiv · 2026
- text2ql: Multi-Target Natural Language Querying via a Language-Agnostic Intermediate RepresentationarXiv · 2026
- SQLoom: Set-Contrastive Learning of Syntactic, Semantic, and Logical Dependencies for Text-to-SQLarXiv · 2026
- Tracing Recurrent and Emergent Hallucination Patterns in Decomposed Text-to-SQL GenerationarXiv · 2026