Designs normalized database schemas from business requirements with tables, relationships, indexes, and migration scripts.
Design a database schema for [application/feature description]. **Requirements:** [describe what the system needs to store and the key operations] **Deliverables:** 1. **Entity-Relationship summary**: List entities, their relationships (1:1, 1:N, M:N), and cardinality 2. **Table definitions** (DDL): - Column names, types, constraints (NOT NULL, UNIQUE, CHECK) - Primary keys (prefer UUID/CUID over sequential for distributed systems) - Foreign keys with ON DELETE behavior - Timestamps: created_at, updated_at on every table 3. **Indexes**: - Primary lookup patterns → indexes - Composite indexes for common WHERE + ORDER BY combos - Partial indexes where applicable 4. **Normalization check**: Confirm 3NF, justify any intentional denormalization 5. **Sample queries**: Top 5 most common queries with their expected EXPLAIN cost 6. **Migration script**: Full CREATE TABLE statements, ready to run **Database**: [PostgreSQL / MySQL / SQLite] **Scale expectations**: [rows per table in 1 year] **Multi-tenancy**: [single-tenant / multi-tenant with tenant_id / separate schemas]
No gallery images yet.
Discussion
Start a discussion about this prompt