P

Prompt ChatGPT to Generate a Database Schema

Designing a database schema is a fundamental step in any software project. A well-thought-out schema ensures data consistency, optimizes query performance, and facilitates long-term maintenance. Yet this task requires expertise in relational modeling, normalization, and appropriate data type choices. ChatGPT can significantly accelerate this process by generating a structured schema from a functional description of your project. By providing the business context, main entities, and expected relationships, you get in seconds a complete SQL schema with primary keys, foreign keys, indexes, and constraints. The AI can also propose optimizations like targeted denormalization for read-heavy cases, or suggest proven patterns such as soft delete or table polymorphism. Whether you are working on a SaaS application, e-commerce, or internal management system, ChatGPT adapts the schema to your chosen DBMS—PostgreSQL, MySQL, SQLite, or SQL Server—while respecting each engine's conventions and native types.

The prompt

ChatGPT

You are a senior database architect with 15 years of experience in relational modeling. I am developing a [PROJECT DESCRIPTION] application. Here are the main business entities: [ENTITY LIST]. The business rules are: [BUSINESS RULES]. The target DBMS is [PostgreSQL/MySQL/SQLite]. Generate a complete database schema in SQL with: 1) All tables with their columns, appropriate data types, and comments, 2) Primary keys (UUID or auto-increment depending on context), 3) Foreign keys with appropriate ON DELETE and ON UPDATE constraints, 4) Indexes on frequently searched or filtered columns, 5) Relevant CHECK and UNIQUE constraints, 6) Audit columns (created_at, updated_at, deleted_at if soft delete), 7) Junction tables for many-to-many relationships. After the SQL, provide a text-format relationship diagram and a list of design decisions with their justification.

Personalize this prompt with Léa

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why it works

This prompt works because it assigns a precise expert role to the AI, steering response quality towards a professional level. The numbered list of expected deliverables forces a comprehensive and structured answer, avoiding common omissions like indexes or constraints. Finally, asking for justification of design choices pushes the AI to reason about each decision rather than apply generic patterns.

Expected result

You will obtain a complete, executable SQL script containing all CREATE TABLE statements with native data types for the chosen DBMS, relational constraints, indexes, and audit columns. The result will also include a text diagram of entity relationships and a document of architectural decisions explaining the choices of normalization, typing, and indexing.

Variants by level

FAQ

Can ChatGPT generate a schema for any DBMS?
Yes, ChatGPT masters SQL syntaxes for PostgreSQL, MySQL, SQLite, SQL Server, and Oracle. It adapts data types (e.g., SERIAL in PostgreSQL vs. AUTO_INCREMENT in MySQL), native functions, and engine-specific extensions. Always specify the target DBMS in your prompt to obtain a directly executable script without modifications.
Does the generated schema respect normal forms?
By default, ChatGPT generates schemas in third normal form (3NF), which eliminates redundancies and transitive dependencies. If your use case requires denormalization for performance reasons (dashboards, reports), specify it in the prompt. The AI can then propose a hybrid schema with denormalized columns or materialized views for read-heavy queries.
How to integrate the generated schema into an existing project with an ORM?
You can ask ChatGPT to generate the schema directly in your ORM format: Prisma models, TypeORM entities, Django models, Drizzle schemas, or Alembic migrations. Simply add to the prompt: "Generate the schema in [ORM_NAME] format" and the AI will produce the corresponding code with decorators, annotations, and configurations specific to the chosen tool.

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 4800+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More prompts to explore

Prompt ChatGPT to Generate a Revision Plan

Preparing for exams or consolidating knowledge requires methodical organization that few students master spontaneously. ChatGPT proves to be a valuable ally...

Prompt ChatGPT to Generate SQL Queries

Generating SQL queries is an essential skill for any developer, data analyst, or database administrator. However, writing complex queries involving multiple joins, nested subqueries, or aggregate functions can be time-consuming and error-prone. ChatGPT radically transforms this practice by allowing you to describe your needs in natural language to obtain optimized and functional SQL queries in seconds.

Prompt ChatGPT to Prepare for an Interview

Preparing for a job interview is a decisive step in any job search. ChatGPT becomes a formidable ally for anticipating questions, structuring your answers, and building confidence before the big day.

Prompt Claude for Analyzing Customer Reviews

Analyzing customer reviews has become a strategic lever for any company looking to improve its products, services, and customer experience.

Prompt Claude for Analyzing Market Trends

Market trend analysis is a strategic exercise that requires cross-referencing economic, behavioral, and sectoral data to identify weak signals and underlying movements. Claude excels at this task thanks to its ability to synthesize large amounts of information, structure multi-dimensional analyses, and formulate well-argued hypotheses.

Prompt Claude for Automating Tasks

Task automation is one of the most powerful uses of Claude. Whether you are an entrepreneur, developer, or corporate professional, you waste considerable time each day on repetitive tasks: sorting emails, extracting data, generating reports, reformatting documents, or classifying information. Claude excels in these scenarios thanks to its ability to understand complex instructions, process structured data, and produce consistent results at scale. Unlike a rigid script, Claude adapts to format variations, handles edge cases, and can explain its decisions. By crafting a well-structured automation prompt, you turn Claude into an operational assistant capable of processing dozens of tasks in seconds with consistent quality. This guide provides optimized prompts to effectively delegate your recurring tasks to Claude, from raw data processing to formatted deliverable generation, including conditional decision-making on information flows.

Go further

Get new prompts every week

Join our newsletter.