🗄️

Database Schema Designer

Design a normalized database schema from application requirements

prompt template
Design a PostgreSQL database schema for: [APP_DESCRIPTION]

**Key entities:** [LIST_MAIN_OBJECTS — e.g., "users, teams, projects, tasks, comments"]
**Key relationships:** [DESCRIBE_RELATIONSHIPS — e.g., "users belong to teams, projects have many tasks"]

For each table provide:
1. **CREATE TABLE** statement with proper column types
2. **Primary keys** (UUID vs serial — recommend with rationale)
3. **Foreign keys** with ON DELETE behavior (CASCADE, SET NULL, RESTRICT)
4. **Indexes** for expected query patterns
5. **Constraints** (UNIQUE, CHECK, NOT NULL)

Also include:
- **Enum types** for status fields and categories
- **Timestamps** (created_at, updated_at) with trigger for auto-update
- **Soft delete** pattern if appropriate (deleted_at column)
- **Row-level security** policies if multi-tenant
- An **ER diagram** in Mermaid syntax

Optimize for:
- Read-heavy queries (assume 100:1 read:write ratio)
- Efficient pagination (cursor-based, not offset)
- Future extensibility without major migrations

How to Use This Prompt

  1. 1Copy the prompt template above
  2. 2Paste into claude
  3. 3Replace [bracketed placeholders] with your specific project details
  4. 4Iterate on the AI output to refine and customize the results