AI Prompts for Cursor for Database Design

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

AI Prompts for Cursor for Database Design
Scroll to explore

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

Design your schema

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.

Design your schema

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.

Design your schema

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.

Design your schema

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.

Design your schema

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.

Design your schema

Stage 2

Design for performance

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.

Design for performance

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 performance

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.

Design for performance

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 performance

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.

Design for performance

Stage 3

Handle migrations

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.

Handle migrations

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.

Handle migrations

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.

Handle migrations

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.

Handle migrations

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.

Handle migrations

Stage 4

Multi-tenant and advanced patterns

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?

Multi-tenant and advanced patterns

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.

Multi-tenant and advanced 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.

Multi-tenant and advanced patterns

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.

Multi-tenant and advanced patterns

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.

Multi-tenant and advanced patterns

Frequently asked questions

What is the most important database design decision?+

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.

When should I normalize versus denormalize my schema?+

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.

How does Cursor help with database design?+

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.

How many indexes is too many?+

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.

Should I use an ORM or raw SQL?+

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.

More Cursor prompt guides