What is a data dictionary? An example and a template you can copy
A data dictionary explains what every table and column means. Here is a worked e-commerce example with real gotchas, and a template you can copy.
Jump to a section
A data dictionary is the document that tells you what every table and column in your database means: the data type, the allowed values, the business rules, and the traps. Most definitions stop there. Below is a full worked example on a realistic e-commerce schema, with the gotchas that actually break numbers, followed by a template you can copy. It also matters more than it used to: the dictionary is what an AI agent needs to read before it writes SQL against your data.
What a data dictionary is
A schema tells you that orders.status is a SMALLINT. A data dictionary tells you that 3 means "shipped", that it meant "completed" until March 2025, and that a revenue report should exclude 4.
It's sometimes described as "data about data", or metadata. In practice it's a table with one row per column of your database, plus a short entry per table. It can live in a spreadsheet, in column comments inside the database, in dbt YAML files, or in a tool that keeps it in sync with the schema.
Older textbooks split dictionaries into two kinds. An active data dictionary is the database's own system catalog, updated automatically when the schema changes. A passive one is maintained separately, by hand. The system catalog is always current but only knows types and keys; the hand-kept document knows what things mean and starts drifting the week after it's written. What works today is a mix: structure pulled from the database automatically, meaning added and kept by people.
A data dictionary example: an online store
The entries that save you are the ones about grain, units, exclusions and history, more than the ones that say an email column holds an email. Here is a dictionary for a small, fictional online store with four tables. Read the "Rules and gotchas" column; that's where the value is.
Table-level entries
| Table | One row is | Primary key | Refresh | Owner | Common joins |
|---|---|---|---|---|---|
orders | One checkout | order_id | Every 15 min from the shop database | E-commerce ops | order_items (one to many), customers (many to one), refunds (one to many) |
order_items | One product line in an order | order_item_id | Every 15 min | E-commerce ops | orders, products |
customers | One registered account | customer_id | Hourly | CRM | orders |
refunds | One refund transaction | refund_id | Every 15 min | Finance | orders |
The "one row is" column (the grain) prevents the most common wrong number in analytics. If you join orders to order_items and then sum an order-level amount, every order with three items gets counted three times.
Column-level entries for orders
| Column | Type | Meaning | Rules and gotchas |
|---|---|---|---|
order_id | BIGINT | ID assigned at checkout | Unique. Never reused. |
customer_id | BIGINT | The account that placed the order | NULL for guest checkouts, so counting distinct customer_id undercounts buyers. |
created_at | TIMESTAMP | When checkout completed | Stored in UTC. Daily reporting uses store time (America/New_York), so convert before grouping by day. |
status | SMALLINT | Fulfillment state, see code list below | Code 3 changed meaning on 2025-03-01. |
subtotal_cents | INTEGER | Item total before discount, tax and shipping | In cents. Divide by 100 for dollars. |
discount_cents | INTEGER | Total discount applied | In cents. 0 when no discount. |
currency | CHAR(3) | Currency charged, ISO 4217 | USD, CAD, GBP. Amounts are not converted; don't sum across currencies. |
is_test | BOOLEAN | Internal QA order | Exclude from every revenue and order count. |
deleted_at | TIMESTAMP | Soft delete time | Row stays in the table. Filter deleted_at IS NULL. |
The code list, with history
Codes get reused when a product changes, and nobody renames the column. So the code list needs dates.
status | Before 2025-03-01 | From 2025-03-01 |
|---|---|---|
| 1 | Awaiting payment | Awaiting payment |
| 2 | Paid | Paid |
| 3 | Completed (shipped, final) | Shipped, return window open |
| 4 | Cancelled | Cancelled |
| 5 | Not used | Returned |
| 6 | Not used | Completed (return window closed) |
When the store launched returns, "completed" moved from code 3 to code 6. A query for completed orders with status = 3 is right for 2024 and quietly wrong for 2025, because it now includes orders that may still come back. A year-over-year comparison built on it compares two different things. The dictionary row is the only place that history lives.
Metric definitions
A dictionary describes columns. The numbers people ask for are built from several of them, so write those down too, next to the columns they use:
| Metric | Definition |
|---|---|
| Net revenue | Sum of subtotal_cents - discount_cents, divided by 100, for orders with status not in (1, 4), is_test = false, deleted_at IS NULL, minus refunds.amount_cents issued in the same period. By order date in store time, per currency. |
| Active customer | A registered customer with at least one paid order in the last 90 days. Guest checkouts are not customers. |
Data dictionary template
Copy this into a spreadsheet, one row per column. The two fields most templates skip are "Rules and gotchas" and "Meaning changed on", and they're the two that prevent wrong numbers.
| Field | What goes in it | Example |
|---|---|---|
| Table | Schema and table name | shop.orders |
| Column | Column name as it appears in the database | status |
| Business name | What people call it | Order status |
| Description | One plain sentence on what the value means | Fulfillment state of the order |
| Data type | Type and length | SMALLINT |
| Nullable | Whether NULL is allowed, and what NULL means | No |
| Allowed values | Range, enum, or link to a code list | 1 to 6, see code list |
| Units and time zone | Cents, dollars, seconds, UTC, local | n/a |
| Rules and gotchas | Filters, exclusions, joins that fan out, known traps | Exclude 1 and 4 from revenue |
| Meaning changed on | Date and what changed | 2025-03-01: code 3 no longer means completed |
| Example value | A real-looking value | 3 |
| Sensitivity | PII, financial, internal, public | Internal |
| Owner | Person or team who answers questions about it | E-commerce ops |
| Last reviewed | Date someone checked the entry | 2026-11-15 |
For the table-level sheet, use: table, one row is, primary key, refresh schedule, source system, owner, common joins.
As CSV headers, ready to paste:
table,column,business_name,description,data_type,nullable,allowed_values,units_timezone,rules_and_gotchas,meaning_changed_on,example_value,sensitivity,owner,last_reviewed
How to create a data dictionary
You don't have to start from a blank sheet. The structure is already in your database; only the meaning needs people.
- Pick the tables people actually query. Start with the 10 to 20 tables behind your main reports, not the whole warehouse.
- Pull the structure automatically. Every major database exposes column names and types through
information_schema. In Postgres this also returns any existing column comments:
SELECT c.table_name,
c.column_name,
c.data_type,
c.is_nullable,
col_description(
format('%I.%I', c.table_schema, c.table_name)::regclass,
c.ordinal_position
) AS description
FROM information_schema.columns c
WHERE c.table_schema = 'shop'
ORDER BY c.table_name, c.ordinal_position;
- Write the grain for each table. One sentence: "one row is one checkout".
- Fill in meaning, starting with the risky columns. Amounts, statuses, timestamps, flags and anything with NULLs. A column named
emailcan wait. - Ask the people who know. Search old Slack threads and PR descriptions for "why is this number different", and ask whoever built the pipeline about codes that changed. This is where the "meaning changed on" entries come from.
- Store it next to the data. In Postgres,
COMMENT ON COLUMN shop.orders.status IS '...'stores the description in the database itself, where tools can read it back. (Source: PostgreSQL docs: COMMENT, https://www.postgresql.org/docs/current/sql-comment.html, checked on 2026-12-01) If you use dbt, write descriptions in your model YAML and turn onpersist_docsto push them to the warehouse as table and column comments on Postgres, Redshift, Snowflake, BigQuery and Databricks. (Source: dbt docs: persist_docs, https://docs.getdbt.com/reference/resource-configs/persist_docs, checked on 2026-12-01) - Give every table an owner and a review date. A dictionary with no owner starts going stale the first time the schema changes.
Data dictionary vs data catalog vs business glossary vs semantic layer
These four get mixed up because they overlap. The short version: the glossary defines words, the dictionary defines columns, the semantic layer defines calculations, and the catalog helps you find all of it.
| Data dictionary | Business glossary | Semantic layer | Data catalog | |
|---|---|---|---|---|
| Describes | Tables and columns | Business terms | Metrics, dimensions, joins | All data assets |
| Example entry | orders.status code 3 means shipped | "Active customer": bought in the last 90 days | net_revenue = sum(...) - refunds | "orders table, owned by ops, used by 14 dashboards" |
| Main reader | Analysts, engineers, AI agents | Everyone in the business | BI tools, AI agents | Anyone looking for data |
| Answers | What does this column mean? | What do we mean by this word? | How is this number calculated? | Where is the data, and who owns it? |
| Typical home | Spreadsheet, column comments, dbt YAML | Wiki, glossary tool | dbt Semantic Layer, Cube, LookML, warehouse semantic views | Atlan, DataHub, Collibra and similar |
A small team rarely needs all four as separate systems. A dictionary with metric definitions next to it covers most of what a glossary and a semantic layer do, and you can find out later whether you need more. If you're weighing the semantic layer part, Does text-to-SQL need a semantic layer? goes deeper.
How AI agents use a data dictionary
When someone asks Claude or ChatGPT "what was net revenue last month?" against your warehouse, the model sees table and column names and has to guess the rest. It will usually write valid SQL. Valid SQL against the store above would still count test orders, add up cents as dollars, double count orders joined to their items, and treat code 3 as completed in both years. Each answer looks plausible and none of them match finance.
The dictionary is what turns those guesses into rules. An agent that reads the orders entry before writing the query knows to filter is_test, divide by 100, avoid the fan-out join and split the status logic at 2025-03-01. When an AI answer is wrong in analytics, the cause is often a missing row like one of these, and a better model won't find it on its own.
Four things matter when the reader is an agent:
- It has to be read at query time. A dictionary in a wiki the agent never opens does nothing. The entries for the tables in the question need to be in the agent's context when it writes the SQL.
- Gotchas beat descriptions. "Order status" tells the model nothing it couldn't guess from
status. "Code 3 changed meaning on 2025-03-01" is the line that changes the answer. - It has to stay current. A new column the dictionary doesn't know about is a column the agent guesses about. Stale entries are worse, because the agent trusts them.
- Corrections need somewhere to go. When someone spots a wrong answer, the fix should land in the dictionary so the next question gets it right, instead of being retyped into the next chat.
Keeping a living data dictionary with Contextflo
Contextflo builds this dictionary for you. Connect a warehouse or database and it generates table and column descriptions from your schema, plus a connected GitHub or GitLab repo and your docs, along with a starter set of metric and business-concept definitions. Your data team reviews a draft instead of filling in a blank spreadsheet. Setup takes about 10 minutes, and the schema re-syncs daily.
Your team then asks questions in Claude or ChatGPT, and the agent reads those descriptions and definitions when it answers, so the rules in the dictionary show up in the SQL. When someone saves a correction, the context sharpens for everyone who asks next. It works with the Claude or ChatGPT subscription your team already pays for, so one AI bill and you pick the model. Pricing starts from $500/month for up to 10 people, unlimited queries, and it's free for one user and one data source.
Here is a more in-depth look at Contextflo and how it works.
What is Contextflo?
Contextflo is a governed context layer between your data and the AI your team already uses. Connect your warehouse once, and your team asks questions in their own Claude or ChatGPT. The model writes and runs the SQL; Contextflo supplies the definitions, the per-user access control, and the audit that make the answers trustworthy. Your data never moves, and you do not need a data team.
How it works
Your team queries in their own Claude or ChatGPT over MCP, so you bring any agent rather than a locked-in bot, and every answer comes back with the SQL shown and access enforced per user.
FAQ
What is a data dictionary? A data dictionary is a reference that describes every table and column in a database. For each column it records the name, data type, what the values mean, allowed values, business rules, the owner and any known gotchas, so people and AI agents read the data the same way.
What should a data dictionary include? At the table level, the grain (what one row is), the primary key, how often it refreshes and who owns it. At the column level, the data type, a plain-language description, allowed values or a code list, units and time zones, business rules, sensitivity, and the date any meaning changed.
What is the difference between a data dictionary and a data catalog? A data dictionary describes the meaning and rules of specific tables and columns. A data catalog is a searchable inventory of all your data assets, usually with lineage, owners and usage. Most catalogs contain a data dictionary as one of their parts.
Do AI agents like Claude and ChatGPT need a data dictionary? Yes, once people rely on the answers. Claude and ChatGPT can write SQL from table and column names alone, but names don't say that amounts are in cents, that test orders must be excluded, or that a status code changed meaning. A data dictionary the agent reads at query time supplies those rules.



