P
💻DeveloppementIntermediateAll AIs

GitHub Copilot Prompt to Generate a Database Schema

GitHub Copilot radically transforms how developers design their databases. Instead of starting from a blank sheet and manually writing each CREATE TABLE statement, you can now describe your business domain in natural language and get a complete schema in seconds. The tool excels particularly in 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 targeted 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 key: by specifying the application context, entity relationships, and business constraints, you get a production-ready schema that follows best practices for normalization and performance.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Generate a complete PostgreSQL database schema for an application of [DESCRIBE_YOUR_BUSINESS_DOMAIN, e.g., meeting room reservation management]. 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 necessary for statuses or categories

Comply with Third 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 this prompt works

This prompt is effective because it provides a structured framework in seven points that guides Copilot toward a comprehensive result, eliminating common oversights like indexes or constraints. The explicit mention of the SQL dialect (PostgreSQL) and normalization level (3NF) reduces ambiguity and produces directly usable code. Finally, the request for comments and example data forces the model to justify its choices and provide a complete deliverable.

Use Cases

Generate a Database Schema

Variants

Expected Output

You will get a complete SQL file containing CREATE TYPE, CREATE TABLE, CREATE INDEX, and INSERT statements, ready to run 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.

Frequently Asked Questions

Can GitHub Copilot generate schemas for databases other than PostgreSQL?

Yes, Copilot supports 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 state the desired normalization level in your prompt (2NF, 3NF, or BCNF). Copilot will then apply the corresponding rules: eliminating partial, transitive dependencies, and so on. Then verify the result by ensuring no non-key column depends on another non-key column. If you spot redundancies, ask Copilot to refactor the relevant table.

Can you 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 the corresponding relationships and Zod validations." Copilot will faithfully translate types, relationships, and constraints into the syntax of the chosen ORM, saving you an extra step in your workflow.

Learn more

Check the full skill on Prompt Guide to master this technique from A to Z.

View on Prompt Guide

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Similar Prompts

💻DeveloppementIntermediateAll AIs

Generate Mocks and Fixtures for Your Automated Tests

A prompt to automatically generate realistic mocks, stubs and data fixtures adapted to your test framework and use cases.

091
💻DeveloppementIntermediateAll AIs

Automatically Generate Unit Tests with AI

Automatically generate an exhaustive unit test suite covering nominal cases, edge cases, and error cases for any source code.

0223
💻DeveloppementIntermediateGemini

Create a Python Automation Script

Create a professional Python automation script with CLI configuration, structured logging, error handling, and tests.

24239
💻DeveloppementAdvancedAll AIs

Analyze and Optimize Algorithmic Complexity

Analyze the Big O complexity of your algorithms and optimize them with appropriate data structures and more efficient algorithms.

40233