New: one score for how consistent your answers are. See more

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.

December 1, 2026•9 min read•Vivek Sah
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

TableOne row isPrimary keyRefreshOwnerCommon joins
ordersOne checkoutorder_idEvery 15 min from the shop databaseE-commerce opsorder_items (one to many), customers (many to one), refunds (one to many)
order_itemsOne product line in an orderorder_item_idEvery 15 minE-commerce opsorders, products
customersOne registered accountcustomer_idHourlyCRMorders
refundsOne refund transactionrefund_idEvery 15 minFinanceorders

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

ColumnTypeMeaningRules and gotchas
order_idBIGINTID assigned at checkoutUnique. Never reused.
customer_idBIGINTThe account that placed the orderNULL for guest checkouts, so counting distinct customer_id undercounts buyers.
created_atTIMESTAMPWhen checkout completedStored in UTC. Daily reporting uses store time (America/New_York), so convert before grouping by day.
statusSMALLINTFulfillment state, see code list belowCode 3 changed meaning on 2025-03-01.
subtotal_centsINTEGERItem total before discount, tax and shippingIn cents. Divide by 100 for dollars.
discount_centsINTEGERTotal discount appliedIn cents. 0 when no discount.
currencyCHAR(3)Currency charged, ISO 4217USD, CAD, GBP. Amounts are not converted; don't sum across currencies.
is_testBOOLEANInternal QA orderExclude from every revenue and order count.
deleted_atTIMESTAMPSoft delete timeRow 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.

statusBefore 2025-03-01From 2025-03-01
1Awaiting paymentAwaiting payment
2PaidPaid
3Completed (shipped, final)Shipped, return window open
4CancelledCancelled
5Not usedReturned
6Not usedCompleted (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:

MetricDefinition
Net revenueSum 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 customerA 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.

FieldWhat goes in itExample
TableSchema and table nameshop.orders
ColumnColumn name as it appears in the databasestatus
Business nameWhat people call itOrder status
DescriptionOne plain sentence on what the value meansFulfillment state of the order
Data typeType and lengthSMALLINT
NullableWhether NULL is allowed, and what NULL meansNo
Allowed valuesRange, enum, or link to a code list1 to 6, see code list
Units and time zoneCents, dollars, seconds, UTC, localn/a
Rules and gotchasFilters, exclusions, joins that fan out, known trapsExclude 1 and 4 from revenue
Meaning changed onDate and what changed2025-03-01: code 3 no longer means completed
Example valueA real-looking value3
SensitivityPII, financial, internal, publicInternal
OwnerPerson or team who answers questions about itE-commerce ops
Last reviewedDate someone checked the entry2026-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.

  1. Pick the tables people actually query. Start with the 10 to 20 tables behind your main reports, not the whole warehouse.
  2. 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;
  1. Write the grain for each table. One sentence: "one row is one checkout".
  2. Fill in meaning, starting with the risky columns. Amounts, statuses, timestamps, flags and anything with NULLs. A column named email can wait.
  3. 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.
  4. 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 on persist_docs to 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)
  5. 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 dictionaryBusiness glossarySemantic layerData catalog
DescribesTables and columnsBusiness termsMetrics, dimensions, joinsAll data assets
Example entryorders.status code 3 means shipped"Active customer": bought in the last 90 daysnet_revenue = sum(...) - refunds"orders table, owned by ops, used by 14 dashboards"
Main readerAnalysts, engineers, AI agentsEveryone in the businessBI tools, AI agentsAnyone looking for data
AnswersWhat 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 homeSpreadsheet, column comments, dbt YAMLWiki, glossary tooldbt Semantic Layer, Cube, LookML, warehouse semantic viewsAtlan, 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:

  1. 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.
  2. 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.
  3. 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.
  4. 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

1
Connect your data
Point Contextflo at your warehouse or database, or upload a CSV. It reaches multiple sources at once, so a single question can span all of them.
2
Bootstrap your context layer and review
Connect your code repo, Notion docs, or a data dictionary, and Contextflo annotates each table in your data source where it can. You review and correct them. That becomes the foundational context layer: your AI agent does not just see tables, it sees the context around them.
3
Define metrics and save golden queries
Pin the verified SQL behind a metric once. Every question then resolves against the same definitions, so the number is consistent no matter who asks or how they phrase it.

Contextflo, explained by our founder.

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.

See it on your own data.

Connect your warehouse and your team can ask Claude about it the same day.

Keep reading