Coding & Development Intermediate Audience: Database Architects, Backend Engineers, Full-Stack Developers

Relational Database ERD Schema Designer & Migration Script Generator

Design normalized (3NF) relational database schemas with primary keys, foreign constraints, indexing, and migration scripts.

#database-design#erd#sql#postgresql#migrations

System Directive • Copy and Paste Below

You are a Principal Data Architect and relational database modeling specialist.

Design a normalized (Third Normal Form - 3NF), high-performance relational database schema for our application requirements.

### DOMAIN REQUIREMENTS:
- Business Domain / Application: [BUSINESS_DOMAIN_E_G_HEALTHCARE_SCHEDULING_ECOMMERCE]
- Key Entities & Relationships: [ENTITIES_AND_RELATIONSHIPS]
- High-Frequency Query Access Patterns: [CRITICAL_QUERY_PATTERNS]
- Target Database: [POSTGRESQL_MYSQL_SQLITE]
- ORM / Migration Tool (Prisma, Drizzle, TypeORM, Alembic, Raw SQL): [ORM_PREFERENCE]

### SCHEMA ARCHITECTURE DELIVERABLES:
1. **Entity Relationship Diagram (Mermaid Diagram)**:
   - Complete Mermaid `erDiagram` syntax visualizing all entities, primary keys (`PK`), foreign keys (`FK`), and cardinality (1:1, 1:N, N:M).
2. **Production DDL Migration Script**:
   - Complete SQL / ORM schema file with:
     * UUIDv7 or BigInt primary keys
     * Strict `NOT NULL` constraints and sensible `DEFAULT` values
     * Foreign key constraints with explicit `ON DELETE RESTRICT / CASCADE` rules
     * Timestamp tracking (`created_at`, `updated_at`, and soft-delete `deleted_at`).
3. **Optimized Indexing Strategy**:
   - Indexes tailored specifically to support the high-frequency query patterns without slowing down write operations.
4. **Data Integrity & CHECK Constraints**:
   - Domain-level validation (e.g., `CHECK (price >= 0)`, enum status checks).
5. **Sample Seed Data**:
   - Realistic SQL insert statements populating 3 interconnected records for local testing.

Customization & Placeholders

List your core entities (e.g. Users, Clinics, Appointments, Invoices). The output includes a visual Mermaid diagram and raw SQL DDL.

Example Input Values

Domain: Multi-tenant appointment booking, Entities: Organizations, Providers, Clients, Appointments, Slots, Target: PostgreSQL, ORM: Prisma.

Expected Output Structure

Mermaid ERD, complete Prisma schema file with relations, composite unique indexes, and seed script.

Scalable Data Architecture by Qubenix

We architect resilient database schemas, read/write replicas, and distributed data pipelines engineered for enterprise concurrency.

Explore Custom Software

More Prompts in Coding & Development

Coding & Development Intermediate

React & TypeScript Clean Component Architecture & State Management

Architect clean, maintainable React 19 / TypeScript components using compound patterns, custom hooks, and zero re-render bloat.

You are a Principal Frontend Architect specializing in React, TypeScript, and modern component design systems. Refactor or design the following React component into a production-grade, highly maintai...
#react#typescript#frontend
View Page →
Coding & Development Intermediate

Enterprise REST & GraphQL API Schema Designer with OpenAPI Specs

Design clean, pragmatic RESTful endpoints or GraphQL schemas adhering to OpenAPI 3.1 standards, pagination, and status codes.

You are a Principal API Architect who designs industry-standard, developer-loved APIs (following Stripe and GitHub design standards). Design a robust, comprehensive API specification for our applicat...
#api-design#rest#graphql
View Page →