28 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.

219
## 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.

94

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.

73

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.

61

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.

55
## 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.

36
## 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.

35

Database Error Fixing Consultant

Rebuild sports databases with this AI prompt, fixing regex parsing errors, filtering pre-debut players, and organizing age, level, and stats data.

29

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.

25
## Role

You are an expert database architect and ISO 11179 standards specialist with enterprise-scale schema standardization experience.

## Task

Analyze the provided database schema and create a comprehensive naming standardization plan that follows ISO 11179 guidelines while ensuring zero disruption to existing applications.

## Context

Inconsistent naming conventions create technical debt, reduce developer productivity, and increase maintenance costs. Common issues include mixed case styles, plural/singular variations, abbreviation misuse, and missing semantic clarity.

Work through this systematically:

1. **Analyze** the current schema to identify naming inconsistencies and anti-patterns
2. **Establish** clear ISO 11179 compliant naming rules (case conventions, pluralization standards, abbreviation guidelines, semantic clarity requirements)
3. **Prioritize** the implementation pl

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.

25
## 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.

24

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.

23

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.

21

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.

21
## 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.

21
## Role

You are a security architecture specialist focused on enterprise access control and zero-trust implementations. You design RBAC (Role-Based Access Control) systems that comply with ANSI INCITS 359 principles, balancing operational efficiency with defense-in-depth security.

## Task

Design and implement a comprehensive RBAC system that addresses unauthorized data exposure, privilege creep, and compliance risks. Your solution must:

- Group permissions by job function, not individuals
- Create hierarchical roles with proper inheritance to eliminate permission duplication
- Enforce separation of duties so no single role holds conflicting permissions
- Apply least-privilege principles throughout
- Account for cross-functional teams and temporary access without compromising the security model
- Include audit trails and permission review processes
- Scale with organizational growth w

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.

21

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.

21

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.

21
## 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.

21
## Role

You are a database architect and data engineer specializing in relational database design, normalization, and SQLite implementation.

## Task

Generate a complete Python system that converts CSV files into a properly normalized, indexed, and constrained SQLite database with validation reporting.

## Context

{{csv-files-and-relationships}}

{{validation-requirements}}

## Requirements

**Data type inference**
- Sample CSV data to determine optimal SQLite column types (INTEGER, REAL, TEXT, BLOB, NULL)
- Handle numeric, date, boolean, and text pattern detection
- Preserve precision and range requirements

**Schema design**
- Apply normalization principles (minimize redundancy, ensure referential integrity)
- Define primary keys for all tables
- Create foreign key constraints based on the described relationships
- Add NOT NULL constraints where business rules require values
- Imple

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.

20

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.

19

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.

17

Database Constraint Design Prompt

Generates SQL constraint definitions, migration scripts, and test cases through an eight-phase implementation process. Runs on ChatGPT, Claude, and Cursor to produce production-ready primary keys, foreign keys, and unique constraints.

17
## Role
Database normalization specialist applying relational theory and normal forms (1NF through 3NF) to eliminate redundancy, update anomalies, and insertion/deletion problems.

## Task
Analyze the provided database table structure and guide step-by-step normalization to third normal form (3NF). Identify violations, explain their real-world consequences, decompose tables to resolve issues, and provide clear before-and-after examples with migration guidance.

## Context
{{table-structure}}

Business context: {{business-context}}

## Analysis Framework

**Step 1: First Normal Form (1NF)**
- Identify repeating groups and multi-valued attributes
- Locate non-atomic values that should be decomposed
- Show how these violations create insertion and update anomalies

**Step 2: Second Normal Form (2NF)**
- Examine composite keys for partial dependencies
- Find non-key attributes that depend on

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.

17

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".

28 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.