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

Answer 3 questions and Léa tailors the prompt to your situation.

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 2500+ 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 Claude for Writing a Professional Bio

Writing a compelling professional bio is a delicate exercise that requires finding the right balance between highlighting your career and authenticity.

Prompt DALL-E for Creating a Content Strategy

DALL-E, the AI image generator developed by OpenAI, has become an essential tool for content creators and strateg

Prompt Gemini for Generating Advertising Visuals

Generating advertising visuals is one of the most powerful use cases for Gemini. With its advanced multimodal capabilities, Gemini allows you to create impactful advertising images in seconds, where a graphic designer would take hours. Whether you are a marketing manager, entrepreneur, or content creator, mastering the right prompts for Gemini transforms your creative workflow. The challenge is not simply to ask for an image, but to structure your request to get a visual that respects your brand identity, captures your target audience's attention, and drives action. A well-constructed prompt integrates the product context, desired visual tone, technical constraints of the advertising format, and essential composition elements. In this guide, you will discover an optimized main prompt for Gemini, its variants according to your expertise level, and best practices for obtaining professional advertising visuals that convert. Each prompt has been tested and refined to maximize rendering quality and commercial relevance.

Prompt Stable Diffusion for Creating a Brand Style Guide

Stable Diffusion is a powerful tool for generating consistent visual elements that form the basis of a professional brand style guide. By leveraging its capabilities, you can create harmonious color palettes, recurring patterns, illustrated typographic styles, and complete moodboards in minutes. The major advantage lies in the ability to iterate quickly through different artistic directions before finalizing your visual identity. Whether you are a designer seeking inspiration or an entrepreneur wanting to lay the visual foundations of your brand, Stable Diffusion allows you to explore hundreds of aesthetic combinations without mobilizing an entire creative team. The secret lies in the precise formulation of your prompts: by specifying the artistic style, color palette, composition principles, and desired brand universe, you obtain visuals directly usable as references for your style guide. This approach does not replace the work of an art director but significantly accelerates the exploration and conceptualization phase.

Prompt Stable Diffusion for Writing a Job Listing

Stable Diffusion revolutionizes how recruiters and HR professionals design their job listings by adding a striking visual dimension.

Prompt Stable Diffusion to Create an Editorial Calendar

Stable Diffusion offers a unique visual approach to designing attractive and functional editorial calendars. Rather than limiting yourself to a simple ta

Go further

Get new prompts every week

Join our newsletter.