Skip to main content
AIPromptIndex
Cursor Coding advanced

Database Schema Designer

Added Apr 1, 2026

You are a database architect with expertise in [DATABASE_TYPE]. Design a complete database schema for [APPLICATION_TYPE] that handles [CORE_FUNCTIONALITY]. Include: entity-relationship diagram description with all tables, columns, data types, and constraints; primary keys and foreign key relationships; indexes for common query patterns; at least one many-to-many relationship with a junction table; enum types or check constraints for status fields; created_at and updated_at timestamps with appropriate defaults; soft delete implementation; and migration scripts in [MIGRATION_FORMAT]. Also provide 3 example queries that demonstrate the most common access patterns and explain your normalization decisions, noting any intentional denormalization for performance.
0
Share
Try in Cursor

About This Prompt

A well-designed database schema is the foundation of any application, and mistakes made at this level are extremely expensive to fix later. This prompt generates production-ready schemas that incorporate best practices like soft deletes, audit timestamps, proper indexing, and thoughtful normalization decisions. The migration script output means you can apply the schema directly to your development database. The example queries help validate that the schema supports your actual access patterns efficiently. Invaluable for greenfield projects, significant feature additions that require new tables, or refactoring legacy schemas.

Variables to Customize

[DATABASE_TYPE]

Which database system

Example: PostgreSQL

[APPLICATION_TYPE]

What the application does

Example: multi-tenant project management SaaS

[CORE_FUNCTIONALITY]

Key features the schema must support

Example: organizations with team members, projects with tasks and subtasks, file attachments, comments with mentions, and time tracking

[MIGRATION_FORMAT]

Migration tool format

Example: Prisma schema with migration SQL

Tips for Best Results

  • Describe your expected query patterns so indexes can be optimized for your use case
  • Mention your expected data volume for appropriate partitioning suggestions
  • Ask about Row Level Security if you are building a multi-tenant system

Example Output

```sql
-- Organizations (tenant table)
CREATE TABLE organizations (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name VARCHAR(255) NOT NULL,
  slug VARCHAR(100) UNIQUE NOT NULL,
  plan_tier VARCHAR(20) DEFAULT 'free' CHECK (plan_tier IN ('free', 'pro', 'enterprise')),
  created_at TIMESTAMPTZ DEFAULT NOW(),
  updated_at TIMESTAMPTZ DEFAULT NOW(),
  deleted_at TIMESTAMPTZ NULL -- soft delete
);

CREATE INDEX idx_organizations_slug ON organizations(slug) WHERE deleted_at IS NULL;

-- Members (junction: users <-> organizations)
CREATE TABLE organization_members (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  organization_id UUID REFERENCES organizations(id),
  user_id UUID REFERENCES users(id),
  role VARCHAR(20) DEFAULT 'member' CHECK (role IN ('owner', 'admin', 'member', 'viewer')),
  UNIQUE(organization_id, user_id)
);
```
database schema-design SQL data-modeling migrations

Get the Best AI Prompts Weekly

Curated prompts, tips, and guides delivered to your inbox every week. Free.