Design a Database Schema
Get a normalized, production-ready database schema for any application with tables, indexes, and constraints.
The Prompt
Design a relational database schema for the following application. Provide: 1. All tables with columns, data types, and constraints (NOT NULL, UNIQUE, DEFAULT) 2. Primary and foreign keys 3. Appropriate indexes for common query patterns 4. An entity-relationship description 5. Any junction tables for many-to-many relationships 6. Notes on normalization choices Output as SQL CREATE TABLE statements (PostgreSQL dialect unless specified). Application description: [DESCRIBE YOUR APPLICATION — e.g., A multi-tenant SaaS app where organizations have multiple users, users can belong to multiple projects, projects have tasks with comments and attachments, and there's a billing/subscription system per organization] Database: [POSTGRESQL/MYSQL/SQLITE]
Example Output
Designed a 9-table schema with a tenants table as the root, cascading foreign keys through organizations → users → projects → tasks, a polymorphic attachments table, and a subscriptions table with a partial unique index ensuring only one active subscription per tenant.
FAQ
Which AI model is best for Design a Database Schema?
Claude Sonnet 4 or GPT-4o. Both handle complex schema design well.
How do I use the Design a Database Schema prompt?
Copy the prompt, replace the [BRACKETED] placeholders with your specific information, and paste into your preferred AI assistant (ChatGPT, Claude, Gemini, etc.). Designed a 9-table schema with a tenants table as the root, cascading foreign keys through organizations → users → projects → tasks, a polymorphic attachments table, and a subscriptions table with a partial unique index ensuring only one active subscription per tenant.
Model Recommendation
Claude Sonnet 4 or GPT-4o. Both handle complex schema design well.