P

GitHub Copilot Prompt for Generating a Database Schema

GitHub Copilot radically transforms how developers design their databases. Instead of starting from a blank page and manually writing every CREATE TABLE statement, you can now describe your business domain in natural language and obtain a complete schema in seconds. The tool excels particularly at generating relational schemas with appropriate primary keys, foreign keys, indexes, and constraints. Whether you work with PostgreSQL, MySQL, SQLite, or SQL Server, Copilot adapts the syntax and data types to the target SQL dialect. This approach significantly accelerates the modeling phase, reduces syntax errors, and allows you to focus on business logic rather than SQL mechanics. A well-crafted prompt is the key: by specifying the application context, entity relationships, and business constraints, you get a production-ready schema that respects normalization and performance best practices.

The prompt

GitHub Copilot

Generate a complete PostgreSQL database schema for a [DESCRIBE_YOUR_BUSINESS_DOMAIN, e.g., meeting room booking management] application. The schema must include:

  1. All necessary tables with their columns, appropriate data types, and explanatory comments
  2. Primary keys (UUID or SERIAL as appropriate)
  3. Foreign keys with appropriate ON DELETE and ON UPDATE actions
  4. Relevant CHECK, UNIQUE, and NOT NULL constraints
  5. Indexes to optimize frequent queries (search, filtering, sorting)
  6. Audit columns created_at and updated_at with default values
  7. ENUM types if needed for statuses or categories

Respect 3rd Normal Form (3NF). Use snake_case for naming. Add SQL comments explaining modeling choices for each table. End with INSERT examples for reference data.

Personalize this prompt with Léa

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

Why it works

This prompt is effective because it provides a structured seven-point framework that guides Copilot to a comprehensive result, eliminating common omissions like indexes or constraints. Explicit mention of the SQL dialect (PostgreSQL) and normalization level (3NF) reduces ambiguity and produces directly usable code. Finally, the request for comments and sample data forces the model to justify its choices and deliver a complete output.

Expected result

You will get a complete SQL file containing CREATE TYPE, CREATE TABLE, CREATE INDEX, and INSERT statements, ready to execute on your PostgreSQL instance. The schema will include between 5 and 15 tables depending on domain complexity, with all relationships correctly defined and comments explaining the business logic behind each modeling decision.

Variants by level

FAQ

Can GitHub Copilot generate schemas for databases other than PostgreSQL?
Yes, Copilot handles all major SQL dialects: MySQL, SQLite, SQL Server, Oracle, and MariaDB. Just specify the target DBMS in your prompt to get the appropriate syntax and data types. For example, MySQL uses AUTO_INCREMENT instead of SERIAL, and SQLite does not natively support ENUM types. Copilot will automatically adapt the schema accordingly.
How can I ensure the generated schema follows normalization best practices?
Explicitly mention the desired normalization level in your prompt (2NF, 3NF, or BCNF). Copilot will then apply the corresponding rules: eliminating partial dependencies, transitive dependencies, etc. Then verify the result by ensuring that no non-key column depends on another non-key column. If you identify redundancies, ask Copilot to refactor the relevant table.
Can I generate Prisma, Drizzle, or TypeORM migrations from the SQL schema?
Absolutely. Once your SQL schema is validated, you can ask Copilot to convert it into a migration file for your ORM. For example: 'Convert this SQL schema into a schema.prisma file with relations and corresponding Zod validations.' Copilot will faithfully translate the types, relationships, and constraints into the syntax of the chosen ORM, saving you an extra step in your workflow.

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

GitHub Copilot Prompt for Generating Advertising Visuals

GitHub Copilot, the AI-powered coding assistant, is not limited to classic code generation. It can also help you create powerful visuals...

GitHub Copilot Prompt for Generating Exercises

GitHub Copilot, the AI-powered coding assistant from GitHub, proves to be a remarkable tool for generating educational exercises suitable for all levels.

GitHub Copilot Prompt for Optimizing SEO

GitHub Copilot, the AI-powered code assistant from GitHub, has become an essential tool for developers looking to optimize the natural referencing of their web projects. Beyond simple code completion, Copilot can generate optimized meta tags, structure schema.org data, create dynamic sitemaps, and implement technical SEO best practices directly in your codebase. By formulating precise prompts in your editor, you can automate the creation of SEO-friendly components, generate appropriate robots.txt files, optimize server-side rendering, and implement lazy loading to improve Core Web Vitals. This programmatic approach to SEO ensures technical consistency across your entire site, eliminates human errors, and significantly accelerates the deployment of optimizations. Whether you're working on a static site, a Next.js application, or an e-commerce project, the following prompts will enable you to fully leverage GitHub Copilot to transform your natural referencing.

GitHub Copilot Prompt for Planning a Product Launch

GitHub Copilot, primarily known as a development assistant, proves to be a remarkably effective tool for structuring product launch plans. By leveraging its contextual generation capabilities, you can transform a simple idea into a detailed action plan covering all critical phases: pre-launch, launch day, and post-launch. Whether you are a product manager, project manager, or startup founder, GitHub Copilot helps you cover all bases by leveraging market best practices.

GitHub Copilot Prompt for Summarizing a Meeting

GitHub Copilot, initially designed for code assistance, proves to be a formidable ally for business productivity tasks, particularly meeting summarization. This page provides an optimized prompt to turn any transcript or notes into a structured report with decisions, actions, and owners.

GitHub Copilot Prompt for Survey Analysis

Survey analysis is a crucial step to extract actionable insights from raw data. GitHub Copilot, through its code generation and contextual understanding capabilities, becomes a powerful ally to automate response processing, identify statistical trends, and produce relevant visualizations.

Go further

Get new prompts every week

Join our newsletter.