name: database-design
description: ALWAYS use this when the hard part is schemas, relationships, constraints, indexes, data integrity, query shape, or migration-safe data modeling.
Database Design
Selective Reading Rule
Start with:
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
Learn to THINK, not copy SQL patterns.
Supplementary References
Start with:
references/senior-master-standard.md
references/schema-routing.md
references/migration-safety.md
Then load only the root markdown files that match the actual database question.
đŸ¯ Selective Reading Rule
Read ONLY files relevant to the request! Check the content map, find what you need.
| File |
Description |
When to Read |
database-selection.md |
PostgreSQL vs Neon vs Turso vs SQLite |
Choosing database |
orm-selection.md |
Drizzle vs Prisma vs Kysely |
Choosing ORM |
schema-design.md |
Normalization, PKs, relationships |
Designing schema |
indexing.md |
Index types, composite indexes |
Performance tuning |
optimization.md |
N+1, EXPLAIN ANALYZE |
Query optimization |
migrations.md |
Safe migrations, serverless DBs |
Schema changes |
â ï¸ Core Principle
- ASK user for database preferences when unclear
- Choose database/ORM based on CONTEXT
- Don't default to PostgreSQL for everything
Decision Checklist
Before designing schema:
Anti-Patterns
⌠Default to PostgreSQL for simple apps (SQLite may suffice)
⌠Skip indexing
⌠Use SELECT * in production
⌠Store JSON when structured data is better
⌠Ignore N+1 queries
1---2name: database-design3description: "---"4---5---6name: database-design7description: ALWAYS use this when the hard part is schemas, relationships, constraints, indexes, data integrity, query shape, or migration-safe data modeling.8---910# Database Design1112## Selective Reading Rule1314Start with:1516- `references/usage-routing.md`17- `references/quality-checklist.md`1819Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.2021> **Learn to THINK, not copy SQL patterns.**2223## Supplementary References2425Start with:2627- `references/senior-master-standard.md`28- `references/schema-routing.md`29- `references/migration-safety.md`3031Then load only the root markdown files that match the actual database question.3233## đŸ¯ Selective Reading Rule3435**Read ONLY files relevant to the request!** Check the content map, find what you need.3637| File | Description | When to Read |38|------|-------------|--------------|39| `database-selection.md` | PostgreSQL vs Neon vs Turso vs SQLite | Choosing database |40| `orm-selection.md` | Drizzle vs Prisma vs Kysely | Choosing ORM |41| `schema-design.md` | Normalization, PKs, relationships | Designing schema |42| `indexing.md` | Index types, composite indexes | Performance tuning |43| `optimization.md` | N+1, EXPLAIN ANALYZE | Query optimization |44| `migrations.md` | Safe migrations, serverless DBs | Schema changes |4546---4748## â ï¸ Core Principle4950- ASK user for database preferences when unclear51- Choose database/ORM based on CONTEXT52- Don't default to PostgreSQL for everything5354---5556## Decision Checklist5758Before designing schema:5960- [ ] Asked user about database preference?61- [ ] Chosen database for THIS context?62- [ ] Considered deployment environment?63- [ ] Planned index strategy?64- [ ] Defined relationship types?6566---6768## Anti-Patterns6970⌠Default to PostgreSQL for simple apps (SQLite may suffice)71⌠Skip indexing72⌠Use SELECT * in production73⌠Store JSON when structured data is better74⌠Ignore N+1 queries