The short version
Document your schema in three layers: (1) name things well so they're self-documenting, (2) add inline column comments for the non-obvious stuff, (3) generate a one-page visual diagram that shows the relationships. Skip the 40-page Confluence page -- nobody reads it.
Layer 1: Name things well
- Tables: plural nouns, snake_case --
order_items, notOrderItems. - Foreign keys:
{table}_id--user_id, notuserId. - Booleans: prefix with
is_orhas_--is_active,has_paid. - Timestamps:
created_atandupdated_at.
Layer 2: Inline comments
PostgreSQL supports column-level comments. Use them for anything that isn't obvious from the name:
COMMENT ON COLUMN orders.status IS
'pending | confirmed | shipped | delivered | cancelled. Never delete orders -- set status to cancelled instead.';
What to comment: enum values, format requirements, business rules, deletion policies. What NOT to comment: id, created_at, obvious foreign keys.
Layer 3: Visual diagram
A one-page ER diagram replaces 40 pages of documentation. Use dbdiagramr -- paste your connection string, get a visual schema in seconds. Show table names, primary keys, foreign key relationships, and non-obvious column types.
The one-page cheat sheet
Create a SCHEMA.md in your repo with table names, key columns, relationships, and a link to your visual diagram. Update it in the same PR that changes the schema.
FAQ
Should I document every table?
No. Document the tables new engineers will touch, the ones with complex business logic, and the ones with non-obvious schemas.
How often should I update the docs?
When you add or change a column. Put the update in your PR template as a checklist item.
What's the best tool for auto-generating schema docs?
dbdiagramr for visual diagrams. dbt's docs generate if you're on dbt.