Database schemas for internal tools

SQL schemas for the internal tools small teams build: tables, keys, constraints and indexes you can run as they are. Each one is written from a blueprint on this site, so it comes with the business rules, screens, phased build prompts and acceptance checks the tables are for. Every schema was run unmodified on two engines, SQLite and PostgreSQL, and loads the blueprint's own seed data, so the example queries return real rows.

36 schemas · MIT licensed · How the blueprints are tested · Markdown version

How these are made

Each schema starts as the data model section of a blueprint: every entity and field in the spec becomes a table and a column, enumerations become CHECK constraints with the spec's exact values, and rules the database cannot enforce in portable SQL are named in a comment on the table instead of being left out. The same file is then run, unchanged, on SQLite and on PostgreSQL, the blueprint's seed data is loaded with foreign keys enforced, and the example queries must return the same rows on both.

The design decisions that came back across these schemas, with excerpts from the SQL, are collected in how to design the database for an internal tool.

What that does not cover: MySQL and other engines, other versions, performance under real load, and migrations from an existing database. Each schema page says so, next to the versions it was run on.