Code GenerationChatLLM DeepAgent

Database Schema Designer

Design a complete database schema with tables, relationships, indexes, and migration scripts for your application.

The Prompt

Design a complete database schema for a [YOUR APPLICATION TYPE].

Database: [PostgreSQL / MySQL / MongoDB / SQLite]
ORM: [Prisma / Drizzle / SQLAlchemy / TypeORM / none]

Application description:
[DESCRIBE YOUR APP'S CORE FUNCTIONALITY AND DATA NEEDS]

Deliverables:
1. ENTITY LIST:
   - All tables/collections with descriptions
   - Fields: name, type, constraints (NOT NULL, UNIQUE, DEFAULT)
   - Primary keys and auto-increment strategy

2. RELATIONSHIPS:
   - One-to-one, one-to-many, many-to-many mappings
   - Foreign key constraints with ON DELETE/UPDATE behavior
   - Junction tables for many-to-many relationships

3. INDEXES:
   - Primary indexes (automatic)
   - Secondary indexes for common query patterns
   - Composite indexes where beneficial
   - Full-text search indexes if applicable

4. SEED DATA:
   - 5-10 realistic sample records per table
   - Consistent relationships across tables

5. MIGRATION SCRIPTS:
   - Initial schema creation SQL
   - ORM migration file if using an ORM
   - Rollback script

6. ER DIAGRAM:
   - Mermaid.js or ASCII diagram of all relationships

7. QUERY EXAMPLES:
   - 5 common queries your app will need
   - With JOINs, aggregations, and filters

Considerations: soft deletes, timestamps (created_at, updated_at), UUID vs auto-increment, normalization level.

Tips for Best Results

  • List your main user stories so the schema covers all data needs
  • Specify expected data volume for index optimization suggestions
  • Ask for a read-optimized vs write-optimized version if unsure

Tags

databaseschemaSQLdata modelingbackend

Related Prompts