What is a database schema diagram?
A database schema diagram shows the physical structure of a relational database: its tables, every column with its SQL type, primary keys, constraints and the foreign keys that link tables.
Read each box as a table. Primary keys are marked at the top, foreign key columns point to the table and column they reference, and constraints such as NOT NULL or UNIQUE sit next to the column they apply to.
When to use a database schema diagram
- Use it to review a migration or a new feature's tables before they reach production.
- Use it to document an existing database for analysts writing queries against it.
- If the audience is non-technical or the design is still conceptual, an ER diagram without types is easier to discuss.
How to make a good database schema diagram
- Use the real table and column names and types from the database, not paraphrases.
- Draw foreign key lines from the exact column to the column it references.
- Group related tables together, such as orders, order_items and payments, to keep lines short.
- Paste your CREATE TABLE statements into MakeCharts to draw the schema from them.