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.

Related prompts

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 JavaScript Code

ChatGPT has become an essential tool for JavaScript developers, whether beginners or experienced. Thanks to its ability to understand natural language instructions, it can generate functional JavaScript code in seconds: utility functions, DOM manipulation, API calls, complex algorithms, or interactive components. But the quality of the code produced directly depends on the precision of the prompt used. A vague prompt will give a generic result, while a structured prompt — specifying the context, technical constraints, expected code style, and edge cases to handle — will produce clean, maintainable code ready to integrate into your project. In this guide, you'll find a main prompt optimized for generating JavaScript code with ChatGPT, as well as three variants tailored to your level. Whether you want to quickly prototype a feature, learn new ES6+ syntaxes, or produce production-ready code with error handling and JSDoc typing, these prompts will save you considerable time while helping you progress.

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 ChatGPT to Write a Report

Report writing is an essential professional skill, whether for activity reports, market analyses, project summaries, or strategic syntheses. Yet structuring ideas, adopting the right tone, and producing a clear, impactful document takes considerable time. ChatGPT radically transforms this process by supporting you at every stage: from defining the outline to the final draft, including rewriting and formatting. With a well-constructed prompt, you get a structured, professional report tailored to your audience in minutes instead of hours. The goal is not to fully delegate writing to AI, but to use it as an intelligent copilot that accelerates your output while keeping your expertise at the center. Whether you are a consultant, manager, analyst, or student, mastering good prompts for report writing gives you a measurable competitive advantage. Discover below the optimized prompt and its variants to produce professional-quality reports with ChatGPT.

Prompt ChatGPT to Write a Thesis

Writing a thesis is one of the most demanding academic exercises: structuring complex thoughts, articulating a research question, synthesizing sources, and producing a coherent argument over dozens of pages. ChatGPT can become a valuable ally in this process, not to write for you, but to support you at every key stage. From defining your research question to building a detailed outline, reformulating your ideas, and writing smooth transitions, the AI helps you overcome writer's block and maintain a rigorous thread. Used intelligently, ChatGPT accelerates the structuring phase, suggests analytical angles you might not have considered, and allows you to produce first drafts of chapters that you will later refine with your expertise. The goal is never to replace your personal reflection, but to catalyze it. This prompt is designed to guide ChatGPT into the role of a virtual thesis supervisor, capable of adapting to your discipline, academic level, and specific institutional requirements.

Go further

Get new prompts every week

Join our newsletter.