Database Schema Designer
Design normalized, production-ready relational database schemas for SaaS applications, e-commerce platforms, and data-intensive systems with complete DDL statements, indexing strategies, and migration plans.
Prompt Content
Copy and paste directly into your model or internal evaluation tool.
<input_handling> Required inputs:
- Domain description (what the application does)
- Key entities and their relationships (even informally described)
- Primary access patterns (what queries will be most frequent)
Optional inputs (will infer if not provided):
- Database engine: assume PostgreSQL
- Scale: assume medium (< 10M rows per table initially)
- Multi-tenancy: assume single-tenant unless stated
- Existing schema: assume greenfield </input_handling>
Step 1: Identify entities and relationships
- Extract all nouns from the domain description as candidate entities
- Classify relationships (one-to-one, one-to-many, many-to-many)
- Identify weak entities and associative tables needed
Step 2: Apply normalization
- Ensure 1NF: atomic values, no repeating groups
- Ensure 2NF: no partial dependencies on composite keys
- Ensure 3NF: no transitive dependencies
- Note any intentional denormalizations for performance with justification
Step 3: Define table structures
- Column names, data types, constraints (NOT NULL, UNIQUE, CHECK)
- Primary keys (surrogate UUID or serial, with rationale)
- Foreign key relationships and cascade behaviors
Step 4: Design index strategy
- Primary key indexes (automatic)
- Foreign key indexes (often forgotten, always needed)
- Query-driven composite indexes for frequent access patterns
- Partial indexes where applicable
Step 5: Provide migration notes
- Table creation order (dependency-safe)
- Seed data requirements
- Soft-delete pattern if needed (deleted_at timestamp) </task>
<output_specification> Format: Structured schema with SQL DDL and explanatory notes Length: 400-800 words Include:
- Entity-relationship summary (text-based ERD)
- SQL CREATE TABLE statements (PostgreSQL syntax)
- Index definitions
- At least 3 design decisions explained with rationale </output_specification>
<quality_criteria> Excellent outputs demonstrate:
- Proper normalization with justified exceptions
- All foreign keys indexed
- UUID or serial PKs with clear rationale
- Timestamps (created_at, updated_at) on all mutable tables
Avoid:
- Storing multiple values in a single column
- Missing foreign key constraints
- Indexes without corresponding query patterns
- Generic column names like "data" or "info" </quality_criteria>
Use Cases
Reference Output
Complete database schema documentation including ER diagram description, CREATE TABLE statements, indexing recommendations, and detailed explanations of three key design decisions.
Scoring Rubric
Evaluation criteria: 1) Appropriate normalization level; 2) Foreign key constraint completeness; 3) Indexing strategy合理性; 4) Timestamp field coverage; 5) Clarity of design decision explanations. Score out of 5, excellent at 4+ points.
User Rating
0 ratingsYour rating
Log in to rate
Comments
0Log in to comment
Related Prompts
Product Marketing - Monochrome Avant-Garde Fashion Portrait
A high-fashion, monochrome editorial prompt for a sharp portrait with dramatic lighting and futuristic accessories, mimicking a luxury brand campaign.
Social Media Post - Magical Night Garden Fashion Portrait
A complex, high-quality prompt for a whimsical fantasy fashion editorial featuring glowing lights and a romantic atmosphere.
Social Media Post - Dreamy Woman in Wildflower Field
A cinematic, photorealistic prompt for a serene portrait of a woman in a field of daisies, emphasizing soft natural light and sharp focus on foreground details.
Social Media Post - Mediterranean Riviera Male Menswear
A comprehensive professional photography prompt for a sharp, high-contrast menswear editorial set against sun-drenched stone architecture.