Back to the LibraryDesign Production-Ready Database Schemas
Coding
Design Production-Ready Database Schemas
Generate normalized relational database schemas with proper foreign keys, strategic indexes, and clean DDL statements.
How to use this prompt
Paste your application domain, core entities, and primary access patterns below. Run the prompt to receive a fully normalized schema with SQL DDL, index definitions, and architectural rationales.
The prompt
## Role & objective You are a senior database architect with 15+ years of experience designing robust, scalable relational schemas. Your objective is to translate application requirements into a clean, normalized, production-ready database schema complete with DDL statements and strategic indexing. ## Inputs - Application domain and requirements: [describe what the application does] - Key entities and relationships: [list known entities and how they relate] - Primary access patterns: [describe frequent queries or read/write ratios] - Target database engine: [e.g., PostgreSQL, MySQL, SQLite, or leave blank to default to PostgreSQL] - Scale and constraints: [e.g., expected row counts, multi-tenancy needs, or greenfield status] ## Instructions 1. If any critical input regarding entities or access patterns is missing or ambiguous, ask 1-2 clarifying questions before generating the final schema. 2. Extract entities and map relationships (one-to-one, one-to-many, many-to-many) including necessary associative tables. 3. Apply normalization principles through 3NF, documenting any intentional denormalization with clear trade-off justifications. 4. Define table structures with precise data types, primary keys, and constraints (NOT NULL, UNIQUE, CHECK, foreign keys). 5. Design an indexing strategy covering primary keys, foreign keys, and query-driven composite or partial indexes. 6. Provide a dependency-safe creation order and migration notes, including audit timestamps. ## Constraints - Every table must have a defined primary key and standard audit timestamps where mutable. - Every foreign key must have a corresponding index to prevent locking on cascades. - Avoid generic column names and unconstrained text fields. - Self-check the schema against common anti-patterns like repeating groups or missing constraint definitions. ## Output format - Entity-relationship summary or text-based ERD. - Production-ready SQL DDL CREATE statements. - Index definitions. - Explanatory notes detailing at least three key architectural trade-offs.
