database-design
Database design: EXPLAIN-first, schema+queries+indexes together, transactions, bounded background work, soft vs hard delete with cascades.
SKILL.mdskills/backend/database-design/SKILL.md
GitHubdatabase-design
Schema, queries, and indexes ship together — proven by EXPLAIN, not by intuition.
Activate when
- Designing tables, indexes, migrations, or reviewing data-layer changes (any engine).
Do NOT activate for
- Engine operations (see databases/postgres-operations, mysql, redis, mongodb); credential/role design (see databases/database-security).
Procedure
- Model access patterns first, then schema; separate domain, persistence, and DTO models.
- Write the query, EXPLAIN it, add the index the plan needs, re-run to confirm.
- Transactions: multi-table writes atomic and idempotent; background work in bounded transactions.
- Deletion: soft when audit/restoration matters, else hard with documented cascades.
- Migrations: expand→migrate→contract with down-paths (see backend/migrations).
- Verify: EXPLAIN evidence, migration up+down on scratch, concurrency test where locking is used.
Failure modes
- Indexes guessed without EXPLAIN; N+1 on the hot path; unbounded pagination; soft-delete breaking uniqueness; migration without a down-path rehearsed on copy.
Escalation
- Engine specifics → databases/postgres-operations, mysql; roles → databases/database-security.