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:
- All necessary tables with their columns, appropriate data types, and explanatory comments
- Primary keys (UUID or SERIAL as appropriate)
- Foreign keys with appropriate ON DELETE and ON UPDATE actions
- Relevant CHECK, UNIQUE, and NOT NULL constraints
- Indexes to optimize frequent queries (search, filtering, sorting)
- Audit columns created_at and updated_at with default values
- 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
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
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
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.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Pour un meilleur résultat, définissez précisément les règles métier (ex. : plage de réservation, conflits). Demandez aussi à Copilot d'ajouter les index sur les colonnes de clé étrangère et les requêtes de sélection fréquentes pour gagner en performance dès le départ.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Similar Prompts
Write an ORM query
Write efficient ORM queries
Implement property-based testing
Add property-based tests
Implement rate limiting
Protect APIs from abuse
Sora Prompt for Creating E2E Tests
End-to-end (E2E) tests are essential for ensuring application reliability, but writing them remains time-consuming and repetitive. Sora, thanks to its advanced generation capabilities, makes it possible to automate the creation of complete E2E test scenarios in seconds. By formulating a precise prompt describing user journeys, expected interactions, and validation criteria, you obtain structured test suites covering nominal cases as well as edge cases. The prompt engineering approach applied to Sora transforms how QA and development teams approach test coverage. Instead of starting from a blank page, you describe the expected behavior of your application in natural language, and Sora generates the corresponding test code with appropriate assertions. This method significantly reduces the time needed to set up an E2E suite while maintaining a professional quality level. Whether you use Playwright, Cypress, or Selenium, the prompts presented here adapt to your technical stack and the complexity of your application.