P

Generate a Database Schema with Gemini

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. Gemini, Google's AI model, excels at generating database schemas thanks to its deep understanding of relational modeling principles, normal forms, and integrity constraints. By providing a structured prompt describing your business domain, main entities, and use cases, Gemini can produce a complete schema with tables, typed columns, primary keys, foreign keys, indexes, and constraints. Whether you work with PostgreSQL, MySQL, SQLite, or any other DBMS, Gemini adapts the generated SQL syntax to the target dialect. This approach significantly accelerates the design phase while adhering to modeling best practices, allowing you to move faster to your application's development.

The prompt

Gemini

You are a senior database architect specialized in relational modeling. Generate a complete database schema for an application of [DESCRIBE YOUR APPLICATION].

Business context:

  • Domain: [e.g., e-commerce, project management, social network]
  • Target users: [e.g., B2B companies, general public]
  • Estimated volume: [e.g., 10,000 users, 1 million transactions/month]

Technical requirements:

  • Target DBMS: [PostgreSQL / MySQL / SQLite]
  • Include precise data types for each column
  • Apply at least 3rd normal form (3NF)
  • Add relevant NOT NULL, UNIQUE, CHECK constraints
  • Define all primary and foreign keys with ON DELETE/ON UPDATE
  • Propose necessary indexes for frequent queries
  • Include audit columns (created_at, updated_at)

Expected output format:

  1. A textual relationship diagram between entities
  2. The complete and executable SQL CREATE TABLE script
  3. A summary table of tables with their role
  4. Recommended indexes with justification
  5. SQL queries for the 5 most common operations

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 combines a precise expert role with explicit technical constraints that prevent Gemini from producing a generic or incomplete schema. Specifying the business context and data volume allows the model to adapt its choices of types and indexing. The structured output format with five deliverables forces a comprehensive and directly usable response.

Expected result

Gemini produces a complete database schema including a textual entity-relationship diagram, ready-to-execute SQL CREATE TABLE scripts with all types, constraints, and indexes, as well as an explanatory table for each table. You also get SQL queries for common operations, allowing you to immediately validate the schema's relevance for your actual use cases.

Variants by level

FAQ

Can Gemini generate a schema for any database management system?
Yes, Gemini is proficient in the SQL syntax of most common DBMS: PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, and Oracle. Simply specify the target DBMS in your prompt so that Gemini adapts data types (e.g., SERIAL vs AUTO_INCREMENT), native functions, and specific extensions. For NoSQL databases like MongoDB, Gemini can also generate collection schemas with JSON Schema validation.
How can I ensure the generated schema respects normal forms?
Explicitly state the desired normalization level in your prompt (2NF, 3NF, BCNF). Also ask Gemini to justify its modeling choices and flag any intentional denormalization. You can add an instruction like "Check that each table respects 3NF and explain any exceptions." This forces the model to analyze its own results and document trade-offs between normalization and performance.
Can I provide an existing schema to Gemini for improvement or completion?
Absolutely. Paste your existing SQL script into the prompt and ask Gemini to analyze it, identify issues (columns without indexes, missing relationships, inappropriate data types), and propose an improved version. This approach is particularly useful for auditing a legacy database or adding new features to an existing schema while preserving compatibility with existing data.

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

GitHub Copilot Prompt for Analyzing an Annual Report

GitHub Copilot, initially designed as a development assistant, also proves formidable for analyzing complex documents such as annual reports.

GitHub Copilot Prompt for Analyzing Customer Reviews

GitHub Copilot, GitHub's AI assistant integrated into code editors, is not limited to code generation. It also excels at analyzing textual data like customer reviews. By leveraging its natural language processing capabilities directly in your development environment, you can automate sentiment extraction, thematic categorization, and trend identification from thousands of user feedback items. Whether you're working on a Python script, a Jupyter notebook, or a Node.js application, Copilot helps you structure your analysis pipelines without leaving your IDE. This approach is particularly valuable for product and data teams who want to turn raw reviews into actionable insights: detecting recurring pain points, evaluating satisfaction by feature, and tracking sentiment evolution over time. The prompt we offer here is designed to guide Copilot in creating a comprehensive analysis system, from data parsing to generating summary reports usable by business teams.

GitHub Copilot Prompt for Analyzing Market Trends

GitHub Copilot, initially designed as a development assistant, proves to be a powerful tool for market trend analysis when used with the right prompts. By leveraging its code generation and data analysis capabilities, you can automate data collection, processing, and visualization directly in your development environment.

GitHub Copilot Prompt for Analyzing User Feedback

Analyzing user feedback is crucial for improving a product, service, or customer experience. However, manually processing hundreds or thousands of comments—whether from reviews, support tickets, NPS forms, or social media—is a significant undertaking. GitHub Copilot, with its natural language understanding capabilities built directly into your code editor, can automate this analysis with remarkable accuracy. By crafting appropriate prompts, you can ask Copilot to categorize sentiments, extract recurring themes, identify priority friction points, and generate actionable summaries for your product teams. Whether you're working with CSV files, JSON exports, or raw data copied from a support tool, Copilot turns your IDE into a full-fledged qualitative analysis platform. This approach is especially useful for developers and product managers who want to integrate feedback analysis directly into their technical workflow, without relying on expensive third-party tools or advanced data science skills.

GitHub Copilot Prompt for Automating Customer Service

GitHub Copilot, GitHub's AI-powered code assistant, proves to be a formidable ally for automating customer service. By leveraging its capabilities...

GitHub Copilot Prompt for Brainstorming Ideas

GitHub Copilot, the AI assistant integrated directly into your code editor, is not limited to auto-completion. It's a formidable brainstorming partner to explore ideas for projects, architectures, or features. By crafting precise prompts in code comments or via Copilot Chat, you can generate dozens of creative leads in seconds, where a classic brainstorming session would take hours. Copilot's major advantage for brainstorming is its technical grounding: unlike a general-purpose tool, it proposes ideas directly exploitable in your development context, with a fine understanding of frameworks, architectural patterns, and technical constraints. Whether you're looking to innovate on an existing product, explore new features for an API, or imagine original solutions to a technical problem, Copilot transforms your editor into a creativity room. This guide provides optimized prompts to make the most of this little-known capability of GitHub Copilot.

Go further

Get new prompts every week

Join our newsletter.