database-design
Installation
SKILL.md
Database Design
Data outlives code. Design the schema for the queries, invariants, and failure modes you must survive, not for the object model of the current service.
1. Start From Access Patterns and Invariants
Before drawing tables, write down:
| Item | Example |
|---|---|
| Entities and owners | payment is owned by Payments; only that service writes it |
| Invariants | A wallet balance is never negative; one active subscription per user |
| Queries and frequencies | "Last 20 transactions by user": 5k req/s, p99 < 20 ms |
| Write rates and growth | 50M rows/month, kept for 10 years |
| Consistency needs | Strong for balances; eventual for analytics |
| Sensitivity and retention | Phone number is PII; logs kept 90 days |
Then choose the store: