# Why Your Text-to-SQL Agent Needs a Business Glossary

Give an LLM a clean database schema and it can write impressive SQL. Then a real user asks *"which products are below their reorder level in the Leeds depot?"* and things fall apart. There is no column called `reorder_level`, and "depot" is a warehouse in one table and a location code in another.

This is the gap between **how the business talks** and **how the database is named**. A business glossary closes it.

## What a Business Glossary Is

A glossary is a set of short definitions for the terms people actually use: what "active customer" means, which column holds the reorder threshold, how a "depot" maps to the warehouse table, and which status codes count as "shipped". Each entry says **what the term means and where it lives in the schema**.

## Why Not Put It All in the Prompt?

For a small database you could. For a real one, the glossary quickly gets too big, and stuffing everything into every prompt wastes tokens and confuses the model. Instead, store the entries in a **vector database** such as Qdrant and retrieve only the terms that match the question. That's RAG, applied to business vocabulary.

## How It Fits the Pipeline

**1.** The user asks a question.\
**2.** The agent searches the glossary for matching terms.\
**3.** The relevant definitions are added to the prompt along with the schema.\
**4.** The model writes SQL that uses the right columns and filters.\
**5.** The query is validated and executed as usual.

## What Changes

Questions that used to produce plausible but wrong SQL now map to the correct tables and conditions. Just as important, the glossary becomes **shared documentation**: the same definitions help new developers and analysts understand the data.

## Practical Tips

Keep entries short and specific. Include synonyms users actually type. Version the glossary alongside your schema, and test it with a benchmark of real questions so you can see when an entry is missing or wrong.

For the full implementation in [ASP.NET](http://ASP.NET) Core with Qdrant and SQL Server, read [**AI Database Agent, Part 4: Adding Business Knowledge**](https://aiengfoundry.com/articles/ai-database-agent-v4-knowledge/) on [AI Engineering Foundry](https://aiengfoundry.com/).
