Guide · Schema documentation

How to document your database schema for AI agents: a template

For data and platform engineers preparing a warehouse for an AI agent.

Updated

To document a database schema for AI agents, record the meaning that column names cannot carry: a business name and description for each table, what each column means and its units, synonyms, primary keys, join keys with cardinality, and the rules that apply. Connect the schema, then sync a data dictionary of markdown files, and the Brain holds it in one place agents can query.

  • Document meaning, not structure: the schema already supplies names and types.
  • Connect Postgres, Trino or Athena for the structure; add a data dictionary for the meaning.
  • By default only schema metadata is read, never rows.

1. Connect the schema

Run one command per source. The CLI reads schema metadata: tables, columns, types, keys and relationships. Use --tables to limit which tables are ingested and --review to stop before publishing so you can check what ingestion proposed.

npx -y @brainbox-labs/cli@latest ingest postgres://user:pass@host/db
npx -y @brainbox-labs/cli@latest ingest trino://user@host:8080/catalog/schema
npx -y @brainbox-labs/cli@latest ingest athena://us-east-1/mydb --review

2. Write a data dictionary

One markdown file per table or domain. Say what the schema cannot: the business meaning, units, allowed values, synonyms, how it joins, and rules that apply. Use plain prose and short lists; the ingest step proposes entities and fields from it.

# orders

One row per customer order. Business name: Order.

- total_cents: order total in cents (divide by 100 for dollars).
- status: placed | shipped | refunded. Refunded orders are excluded from revenue.
- customer_id: joins to customers.id (many orders per customer).
- Also called: purchase, booking.

3. Sync the dictionary and keep it current

Point sync at the folder. Run --dry-run first to see the diff. Re-run it when the dictionary changes: new and edited files are ingested and unchanged ones are skipped.

npx -y @brainbox-labs/cli@latest sync ./data-dictionary --namespace data-dictionary --dry-run
npx -y @brainbox-labs/cli@latest sync ./data-dictionary --namespace data-dictionary

What is and is not read

By default only schema metadata is read, never rows. Opt-in column profiling (--profile-data) samples rows to compute statistics, and full mode also sends enum values and JSON key shapes. Skip specific columns with --skip-profile-columns.

What to document and where it lives in the Brain
Document thisWhy an agent needs itStored as
A business name and description per tablePicks the right table by meaningEntity name and description, with runtimeBinding
What each column means, with units and encodingsReads values correctlyField description and annotations
Synonyms and known typosMatches your words to columnsAliases on entities and fields
Primary keys and natural keysIdentifies a rowEntity keys
How tables join, and one-to-many or many-to-manyJoins safelyRelationship with cardinality and join keys
Business rules and their conditionsApplies your policiesRules
Sensitive columnsHandles them with careField isSensitive flag

FAQ

Which databases can I connect?
Postgres, Trino and Athena, plus SQL files. Trino and Athena have no enforced keys or indexes, so only tables and columns are read; declare keys in your dictionary.
Do I have to write all of this by hand?
No. Ingestion proposes entities, relationships and fields from the schema and your docs, and a person reviews it. You add what the schema cannot say.
What file formats can the data dictionary use?
md, txt, html, pdf and docx. Convert other exports, such as CSV or JSON, to markdown first.
How do I keep the dictionary current?
Keep it in a folder and run brainbox sync on it. New and edited files are ingested and unchanged ones are skipped.

Give your agents a brain.

Sign in and ask your first question.

Book a Demo