27 AI Prompts for Database Design

The best Database Design prompts in the Coding library. Tested on ChatGPT, Claude, Gemini and every major model.

Browse the prompts

## Role
You are an SQL optimization specialist who untangles complex queries and transforms them into clear, performant statements.

## Task
Analyze the provided SQL query and rewrite it for clarity and performance. Map the true data relationships, eliminate unnecessary complexity, and produce a query that future developers can understand and maintain.

## Context
{{query-and-schema}}

Include your existing query, relevant table definitions with columns and relationships, and a description of the expected result (what data you're trying to retrieve).

## Process
1. **Query Analysis**: Dissect the query to identify all tables, join conditions, and intended results. Flag problematic patterns:
   - Ambiguous outer joins
   - Unnecessary cross joins creating Cartesian products
   - Nested queries hiding business logic
   - Implicit joins in WHERE clauses

2. **Schema Understanding**: Review 

SQL Query Optimization and Join Rewriting Prompt

Analyzes and rewrites complex SQL queries with tangled joins into clear, performant statements with explicit join syntax and optimized structure. Runs on ChatGPT, Claude, Gemini, and Grok.

172
## Role
You are a SQL query architect specializing in production-ready queries that follow Joe Celko's SQL Programming Style, prioritizing readability, maintainability, and performance optimization.

## Task
Generate SQL queries compliant with Celko's formatting standards. Before writing any query, analyze the schema, identify potential performance bottlenecks, choose appropriate join strategies, and structure for maximum readability.

## Context
{{database-requirements}}

*Provide your database schema, the desired output/results you need, and any performance constraints or compliance requirements.*

## Query Standards

**Formatting:**
- Each major clause (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY) starts on a new line
- Subqueries indented 4 spaces
- Column lists vertically aligned
- Logical operators (AND, OR) at the beginning of lines
- Uppercase SQL keywords, lowercase identifier

SQL Query Generator With Celko Style Standards

Generates production-ready SQL queries following Joe Celko's formatting standards, with schema analysis and performance optimization. Runs on ChatGPT, Claude, and Cursor to produce readable, maintainable database code.

83

Database Schema Design Prompt for SQL and Relational Models

Generates normalized relational database schemas with entity definitions, foreign key constraints, and denormalization trade-offs. Runs on ChatGPT, Claude, and other text models to produce SQL CREATE statements following Third Normal Form principles.

64

SQL Query Performance Analysis Prompt

Generates a detailed performance diagnosis of SQL queries, complete with execution plan breakdowns, index recommendations, and optimized rewrites. Runs on ChatGPT, Claude, Gemini, and Grok to help database administrators and developers eliminate bottlenecks.

55

Data Access Control Implementation Guide Builder

Generates a complete database access control framework that balances security with operational efficiency. Runs on ChatGPT, Claude, Gemini, and Grok to produce role-based permissions, audit mechanisms, and phased rollout plans.

48
## Role

You are a database migration architect specializing in zero-downtime transformations for production systems where data integrity failures carry regulatory and business consequences. You apply database refactoring principles with precision: every schema change must be incremental, reversible, and validated. Your approach prioritizes correctness over speed.

## Task

Create a phased migration plan that transforms {{source-schema}} into {{target-schema}} while maintaining 100% uptime and data integrity throughout. The plan must accommodate {{business-constraints}} and execute within safe operational windows.

## Context

The database supports 24/7 operations with multiple dependent applications, some with undocumented dependencies. Previous migration attempts resulted in rollbacks. The transformation must proceed without disrupting global operations or risking data loss.

## Migrat

Database Migration Step List Generator

Generates a phased, zero-downtime database migration plan with DDL/DML scripts, validation queries, and rollback procedures for production systems. Runs on ChatGPT, Claude, and Cursor to output executable SQL code and risk analysis.

30
## Role

You are a database performance engineer specializing in query optimization. Analyze execution plans to identify bottlenecks and rewrite queries using proven optimization techniques. Your recommendations are specific, surgical, and grounded in execution mechanics.

## Task

Optimize the provided slow query by:

1. **Execution Plan Analysis**: Decode the current execution plan, highlighting expensive operations (table scans, inefficient joins, nested loops on large sets) and their root causes
2. **Bottleneck Identification**: Pinpoint specific issues—missing indexes, poor join order, unnecessary subqueries, cardinality misestimates, outdated statistics
3. **Optimization Strategy**: Apply targeted techniques including filtered indexes, proper join types, subquery elimination, index-aware restructuring, and database-specific features
4. **Rewritten Query**: Provide the optimized que

Database Query Optimization Prompt for SQL Performance

Analyzes execution plans, identifies bottlenecks, and rewrites slow SQL queries into high-performance operations. Runs on ChatGPT, Claude, Gemini, and Grok for database optimization.

24

Design Role-Based Access Controls

Generates a complete RBAC implementation with role hierarchies, permission matrices, and SQL scripts for database systems. Runs on ChatGPT, Claude, and other text models to produce security-compliant access control documentation and code.

19

Data Model Flaw Analysis Prompt

Audits entity-relationship diagrams and database schemas against Chen's ER Model principles, identifying structural flaws in entities, relationships, attributes, and normalization. Runs on ChatGPT, Claude, Gemini, and Grok.

18
## Role

You are an expert T-SQL database architect specializing in stored procedure design, drawing on set-based query techniques and enterprise optimization patterns.

## Task

Draft production-ready T-SQL stored procedures that implement the specified business logic with modular design, comprehensive error handling, proper transaction management, and high-performance set-based operations.

## Context

You are building for enterprise environments where performance, security, and maintainability are critical. Each procedure must:

- **Validate parameters** to prevent SQL injection and invalid input
- **Use set-based operations** instead of cursors or iterative logic
- **Manage transactions** with appropriate isolation levels and rollback handling
- **Handle errors** with try-catch blocks, meaningful error messages, and logging where appropriate
- **Include inline comments** explaining l

Stored Procedure Generator for T-SQL

Generates production-ready T-SQL stored procedures with modular design, error handling, and set-based operations. Runs on ChatGPT, Claude, and other text models to produce enterprise-grade database code.

18
## Role
You are a metadata governance specialist who creates data dictionaries that bridge technical precision and business clarity, following ISO/IEC 11179 standards. Your documentation prevents costly misinterpretation by ensuring every definition is unambiguous and accessible to both technical and non-technical stakeholders.

## Task
Create a comprehensive data dictionary that documents every table and column with business definitions, technical specifications, ownership details, and relationships. The dictionary must follow ISO/IEC 11179 metadata registry standards while remaining readable by all stakeholders.

## Context
{{database-schema}}

Analyze the schema structure, identify relationships, clarify business context, define ownership boundaries, and ensure compliance with metadata standards.

## Output
Structure the data dictionary as follows:

### Overview
- Database purpose and

Data Dictionary Generator Prompt for Database Schema

Generates a complete data dictionary from your database schema, documenting every table and column with business definitions, technical specifications, ownership, and relationships following ISO/IEC 11179 standards. Runs on ChatGPT, Claude, Gemini, and Grok.

17

CSV Import System Design Prompt

Generates a complete, production-ready CSV import function with pandas-based parsing, row-by-row validation, atomic transactions, and error reporting. Runs on ChatGPT, Claude, and Cursor to output Python code with database integration.

17

Database Naming Convention Standardization Prompt

Generates an ISO 11179-compliant database naming standardization plan with rename scripts, rollback procedures, and dependency mapping. Runs on ChatGPT, Claude, and other code-capable models.

17

Database Indexing Strategy Analyzer

Analyzes table schemas and query patterns to recommend optimal indexing strategies with actionable CREATE INDEX statements and performance trade-off assessments. Runs on ChatGPT, Claude, Gemini, and Grok.

17
## Role
You are an expert data quality architect and database validation specialist with deep knowledge of the DAMA Data Management Body of Knowledge and practical database design experience.

## Task
Design comprehensive data validation rules that enforce the six core data quality dimensions—accuracy, completeness, consistency, timeliness, uniqueness, and validity—to prevent data quality issues at the point of entry. Translate business requirements into robust technical constraints that maintain data integrity without hindering user productivity.

## Context
Catching errors during data entry is exponentially more cost-effective than downstream remediation. Analyze the provided schema and business requirements, then systematically design validation rules across all six quality dimensions, including:

- Check constraints for value ranges and format validation
- Foreign key relationships f

Set Data Validation Rules

Generates SQL data validation rules across six quality dimensions (accuracy, completeness, consistency, timeliness, uniqueness, validity) for database schemas. Runs on ChatGPT, Claude, Gemini, and Grok.

17
## Role

You are an expert database architect specializing in schema optimization, normalization analysis, and redundancy elimination.

## Task

Analyze the provided database schema to identify redundant tables that waste storage, degrade performance, violate normalization principles, or create maintenance overhead. Deliver a comprehensive audit report with prioritized remediation recommendations.

## Context

Work through the analysis systematically:

1. **Map relationships**: Parse the schema to document all table relationships, foreign keys, and data flows
2. **Detect duplicates**: Compare column structures across tables to identify duplicate or overlapping data storage
3. **Flag isolation**: Identify tables with no foreign key relationships, suggesting disconnection from the core data model
4. **Examine naming**: Spot naming patterns indicating temporary, backup, experimental, or dep

Find Redundant Tables in Database Schema

Analyzes database schemas to identify redundant, orphaned, and duplicate tables that waste storage or violate normalization principles. Runs on ChatGPT, Claude, Gemini, and Grok to deliver a prioritized audit report with remediation recommendations.

15

Database Table Normalization Prompt for ChatGPT

Analyzes database table structures and guides step-by-step normalization to third normal form (3NF), identifying violations and providing SQL migration scripts. Runs on ChatGPT, Claude, and Gemini.

13

Database View Design Prompt for SQL Abstraction Layers

Generates production-ready SQL CREATE VIEW statements that transform complex schemas into secure, business-friendly abstraction layers with performance optimization and example queries. Runs on ChatGPT, Claude, Gemini, and Grok.

13
## Role
You are a database architecture specialist who designs normalized, scalable relational schemas from business requirements.

## Task
Transform the provided application requirements into a well-designed relational database schema. Extract entities, identify attributes, map relationships, apply normalization through 3NF, and anticipate growth patterns.

## Context
Application and data requirements:
{{application-requirements}}

Apply these design principles:
- Single-column primary keys (auto-increment integer or UUID)
- Foreign keys with explicit cascading rules (ON DELETE/UPDATE)
- No calculated or derived fields in tables
- Minimize nullable fields; use separate tables for optional data
- Junction tables with composite keys for many-to-many relationships
- snake_case naming, singular table names
- created_at and updated_at timestamps on all tables
- Design for common query patter

Database Schema Generator Prompt for ChatGPT

Generates normalized, scalable relational database schemas from business requirements, complete with SQL CREATE statements, ERD diagrams, and design rationale. Runs on ChatGPT, Claude, and other code-capable text models.

12
## Role
You are a database architecture specialist who translates ERD diagrams into production-ready schemas, preserving all relationships, constraints, and cardinality rules.

## Task
Convert the provided ERD into complete, executable DDL statements that maintain data integrity and business logic.

Analyze before generating:
- Each entity and its attributes
- All relationships and their cardinality (1:1, 1:N, M:N)
- Constraints that enforce business rules
- Naming patterns that preserve business context

## Context
{{erd-diagram}}

Target database: {{database-system}}

Naming convention: {{naming-convention}}

## Output
Provide executable DDL organized as:

**1. Table Definitions**
- CREATE TABLE statements with all columns and explicit data types
- Inline PRIMARY KEY declarations

**2. Foreign Key Constraints**
- All FOREIGN KEY constraints with proper REFERENCES
- ON DELETE/ON UPDATE 

ERD to Database Schema Converter

Converts Entity-Relationship Diagrams into production-ready DDL statements with preserved constraints, cardinality rules, and business logic. Generates executable SQL schema code for ChatGPT, Claude, or Cursor.

12

Data Archiving Strategy Prompt for Database Design

Generates a phased data archiving strategy that categorizes records by business value, regulatory retention, and access frequency to reduce production database size while maintaining compliance. Runs on ChatGPT, Claude, Gemini, and Grok.

12

SQLite Database Loader From CSV Generator

Generates a complete Python system that converts CSV files into a normalized, indexed SQLite database with automatic type inference, constraint validation, and detailed import logging. Runs on ChatGPT, Claude, and Cursor.

12

SQL Migration Generator for Laravel Schema Changes

Generates timestamped Laravel migration files with atomic up() and down() methods, constraint management, and rollback strategies. Produces production-grade PHP code for ChatGPT, Claude, or Cursor.

12
## Role

You are an expert Database Performance Architect specializing in SQL Server index maintenance using Kimberly Tripp's methodologies. You guide users through a comprehensive, phased maintenance strategy tailored to their specific environment.

## Task

Create a complete index maintenance plan that progresses through 7-10 dynamic phases based on the user's database complexity. Each phase builds on the previous, moving from discovery and assessment through strategy design, automation, and long-term optimization.

Adapt the depth and number of phases to match:
- Database size and transaction volume
- Business criticality and uptime requirements  
- Current fragmentation and performance baseline
- Available maintenance windows
- Team technical expertise level

## Context

**User Environment:**
{{database-environment}}

**Current Pain Points:**
{{performance-issues}}

## Process

### P

SQL Server Index Maintenance Plan Generator

Generates a phased SQL Server index maintenance strategy using Kimberly Tripp's methodologies, tailored to your database size, transaction volume, and maintenance windows. Produces ready-to-run T-SQL scripts for ChatGPT, Claude, or Cursor.

11

What are AI prompts for Database Design?

AI prompts for Database Design are engineered instructions that already work. These are not one-line questions. Each one fixes the role, the context, the task and the output format before you type a word, so you get a usable result on the first run instead of the fourth.

They cover the work Database Design actually get asked for: research and briefs, copy and content, analysis and reporting, planning, outreach and the admin that eats the day. Open a card to see the full prompt and the output it returns.

Popular on this page right now: "SQL Query Optimization and Join Rewriting Prompt", "SQL Query Generator With Celko Style Standards", "Database Schema Design Prompt for SQL and Relational Models".

27 on this page, every one scoped to Database Design. Free to read, free to copy.

Why these prompts work for Database Design

A weak prompt costs you the hour you were trying to save: you rewrite it three times, get something generic, then finish the job by hand. An engineered prompt front-loads that thinking once.

In Database Design that means first drafts you can send, analysis you can act on, and the repetitive work handed off, so the time goes into judgement instead of typing.

Every prompt here was written for a real job and tested against the models people actually use. Nothing scraped from a thread.

How to use these prompts

Open a prompt, copy it, and replace the [bracketed] variables with your own product, audience or topic. The structure around them stays as is. That structure is the part doing the work.

Paste it into ChatGPT, Claude, Gemini, Grok or the model you already use. If the output drifts, tighten the context line instead of rewriting the whole prompt.

No account needed to copy one. No setup, no extension, nothing to install.

Which AI tool works best for Database Design prompts?

Text prompts here run well in ChatGPT, Claude, Gemini and Grok; image prompts target Midjourney and Nano Banana. Each card lists the models it was tested with.

Are these AI prompts free to use?

A big part of the library is free: open a prompt, copy it, use it. Premium packs and the Complete AI Bundle unlock the full collection with lifetime updates.

How do I adapt these prompts to my use case?

Start with the [variables]: niche, audience, constraints. If the result still misses, add one example of the output you want. A single good example beats three extra instructions.

For a prompt built from scratch, the Start Now card above opens the custom prompt generator.

Related resources

Get smarter on AI every week

One email a week with the best new prompts, tools, and model updates. Unsubscribe anytime.

Join 100,000+ subscribers. One email a week, real prompts, tools, and model updates. Unsubscribe anytime.