20 tested prompts across 4 stages. Works with ChatGPT, Claude, and Gemini.

Design scalable, well-structured databases using Cursor to make better decisions about schemas, relationships, and performance. This guide walks you through every stage of Cursor for Database Design, from Design your schema all the way through Multi-tenant and advanced patterns, with a tested, copy-ready prompt at each step. Each stage targets a specific phase of the process so you always know exactly what to ask and what output to expect. Works with ChatGPT, Claude, and Gemini and any other major AI tool.
Stage 1
Start here to design a schema that fits your data model and will scale with your application.
Design a database schema
Design a database schema for [DESCRIBE THE APPLICATION]. I'm using [POSTGRESQL / MYSQL / SQLITE]. Give me: table names, columns with data types, primary and foreign keys, and any constraints or defaults.
Model entity relationships
Help me model the relationships between these entities: [LIST ENTITIES AND DESCRIBE HOW THEY RELATE]. Determine: one-to-one, one-to-many, or many-to-many relationships, and the correct foreign key structure.
Choose data types
What is the right data type for these fields in [POSTGRESQL / MYSQL]: [LIST FIELDS AND DESCRIBE WHAT THEY STORE]. Explain the tradeoffs between similar types like varchar vs text, int vs bigint, timestamp vs timestamptz.
Normalize the schema
Review this schema for normalization: [PASTE SCHEMA]. Identify violations of 1NF, 2NF, or 3NF and suggest how to restructure. Also tell me when to intentionally denormalize for performance.
Handle soft deletes
I want to implement soft deletes for [TABLE NAME]. Show me the schema change (deleted_at column), how queries need to filter, and the tradeoffs versus hard deletes.
Stage 2
These prompts help you make schema and indexing choices that keep queries fast.
Design indexes
Design indexes for this schema based on the queries I will run: [PASTE SCHEMA AND LIST COMMON QUERIES]. For each index: which columns, index type, and the query it speeds up.
Partition large tables
This table will grow to hundreds of millions of rows: [DESCRIBE TABLE]. Should I use table partitioning? If so, what partition key and strategy (range, list, hash) would work best?
Design for read performance
My application is read-heavy with these query patterns: [LIST QUERIES]. Should I denormalize, add materialized views, use read replicas, or use a caching layer? Recommend the right approach for my scale.
Audit index usage
Review these indexes and tell me which might be unnecessary, missing, or suboptimal: [PASTE INDEX DEFINITIONS AND COMMON QUERIES]. Indexes have a write cost — I only want the ones that earn their keep.
Design for full-text search
I need to add full-text search to [DESCRIBE WHAT USERS SEARCH FOR]. Should I use [POSTGRESQL FULL-TEXT SEARCH / ELASTICSEARCH / TYPESENSE / OTHER]? Show me how to set up the chosen approach.
Stage 3
Use these prompts to write and apply database migrations safely.
Write a migration
Write a database migration to [DESCRIBE THE CHANGE: ADD COLUMN, RENAME COLUMN, CHANGE TYPE, ADD TABLE, ADD INDEX]. Include the UP migration and the DOWN rollback. Make it safe for production.
Migrate without downtime
I need to [DESCRIBE THE SCHEMA CHANGE] on a table with millions of rows and cannot take downtime. What is the safe migration strategy? Walk me through the steps.
Backfill data
I added a new column and need to populate it for existing rows: [DESCRIBE THE BACKFILL]. Write a safe backfill migration that processes in batches to avoid locking the table.
Review a migration
Review this migration for safety issues before I run it on production: [PASTE MIGRATION]. Check for: table locks, missing indexes on foreign keys, data loss risks, and whether rollback works.
Rename a column safely
I need to rename [COLUMN] in [TABLE] which is used by my production application. Walk me through the zero-downtime rename strategy using a multi-step migration.
Stage 4
These prompts help you implement advanced patterns like multi-tenancy, partitioning, and complex joins.
Design for multi-tenancy
I'm building a multi-tenant SaaS application. Compare the three multi-tenancy approaches for my database: single database with tenant_id column, separate schemas per tenant, or separate databases. Which fits my scale and requirements?
Design audit logging
Design an audit log system for my database that tracks who changed what data and when. Show the audit table schema, how to populate it (triggers vs application code), and query patterns.
Handle time-series data
I need to store [DESCRIBE TIME-SERIES DATA: EVENTS, METRICS, LOGS]. Should I use [POSTGRESQL WITH TIMESCALEDB / INFLUXDB / A STANDARD TABLE WITH INDEXES]? Show me the recommended schema.
Design role-based access
Design a role-based access control (RBAC) system for my database. I need users to have different permissions on different resources. Show the schema and how to query for permission checks.
Handle JSON data
I need to store [DESCRIBE FLEXIBLE/VARIABLE DATA] in PostgreSQL. Should I use a JSONB column or separate tables? Show me the schema and how to query JSONB fields with indexes.
Getting your entity relationships right early. Changing a one-to-many relationship to many-to-many after launch requires a table migration and data backfill. Model your domain carefully before writing production code.
Normalize first for correctness. Denormalize selectively for performance only when profiling shows it is necessary. Premature denormalization creates data consistency problems without delivering real performance benefits.
Cursor can generate schemas from your application description, review existing schemas for issues, write migrations, and help you think through tradeoffs like indexing strategies and multi-tenancy patterns.
Every index speeds up reads but slows down writes. A table with 20 indexes will have slow INSERT and UPDATE operations. Index the columns in your most common WHERE and JOIN clauses. Remove indexes that are never used.
ORMs are faster for standard CRUD. Raw SQL is better for complex queries, performance-critical paths, and when ORM abstractions get in the way. Most production apps use both: ORM for simple operations, raw SQL or query builders for complex ones.
AI Prompts for Cursor for SQL
Write, debug, and optimize SQL queries faster using Cursor to work with databases more effectively..
See promptsAI Prompts for Cursor for Backend Development
Build scalable, maintainable backend systems faster using Cursor's AI assistance for APIs, services, and data layers..
See promptsAI Prompts for Cursor for Performance Optimization
Identify and fix performance bottlenecks in your codebase using Cursor to deliver faster applications..
See prompts