Skip to main content

Claude Prompt to Design a Database Schema from Requirements

Design a normalized database schema from business requirements: tables, relationships, indexes, constraints, and migration scripts.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Design a PostgreSQL database schema for project management with time tracking. Requirements: users can create projects, add tasks, track time, generate invoices, manage teams. Create: 1) Entity-relationship diagram (Mermaid), 2) Table definitions with columns, types, and constraints, 3) Normalization to 3NF with strategic denormalization (explain trade-offs), 4) Foreign key relationships with cascade rules, 5) Indexes for tasks by project, time entries by date range, invoices by client query patterns, 6) Check constraints and domain rules, 7) Soft delete vs hard delete strategy, 8) Audit columns (created_at, updated_at, deleted_at), 9) Migration scripts in Laravel migrations, 10) Seed data for development. Include: estimated row counts, partitioning strategy for time_entries (millions of rows), and a query performance analysis for the top 5 queries.

What this prompt does

This prompt converts business requirements into a concrete [database_type] schema for your [domain]. You hand it [requirements] in plain language, and it returns a Mermaid ER diagram, full table definitions with columns and constraints, normalization to your chosen [normal_form], foreign keys with cascade rules, and indexes targeted at your [query_patterns]. It rounds out the design with check constraints, a soft-versus-hard delete strategy, audit columns, and migration scripts in [migration_tool].

The structure works because it front-loads the decisions that are expensive to change later. By asking for normalization trade-offs, a partitioning strategy for [large_table], and a performance analysis of your top [query_count] queries, it pushes you to think about scale before you write application code. Getting tables, constraints, and indexes right up front is far cheaper than re-architecting a schema after launch. It also asks for a soft-versus-hard delete strategy, audit columns like created_at and updated_at, foreign key cascade rules, and check constraints, so the schema encodes business rules at the database level instead of leaving them to application code that can drift or be bypassed. Seed data for development rounds it out so a new contributor can spin up a realistic environment quickly.

When to use it

  • You are starting a new application and want a solid schema before writing any backend logic.
  • You have rough [requirements] and need them translated into normalized tables and relationships.
  • You expect a [large_table] to grow into millions of rows and need a partitioning strategy early.
  • You want migration scripts generated in [migration_tool] rather than hand-writing them.
  • You need a visual ER diagram to align stakeholders or document the data model.
  • You want index recommendations tied to specific [query_patterns] instead of guessing.

Example output

Expect a layered deliverable: a Mermaid ER diagram first, followed by CREATE TABLE-style definitions with types and constraints, a normalization discussion explaining where you stay at [normal_form] and where you denormalize, foreign key and cascade rules, an index list mapped to your [query_patterns], and [migration_tool] migration files. Seed data and a short performance analysis of the top [query_count] queries typically close it out.

Pro tips

  • Make [requirements] as concrete as possible; listing the real entities and actions ("track time, generate invoices, manage teams") produces a far more accurate schema than abstract goals.
  • Be honest about [normal_form]; asking for "3NF with strategic denormalization" gives you cleaner trade-off reasoning than demanding strict normalization everywhere.
  • Name your actual [query_patterns] so the index recommendations are useful rather than generic.
  • Identify the real [large_table] up front, because partitioning advice is only meaningful when it targets the table that will actually grow.
  • If you use a specific ORM, set [migration_tool] to match it (Laravel migrations, Alembic, Prisma) so the output drops straight into your project.
  • Iterate by pasting the generated schema back and asking it to add a new entity or stress-test a particular query path.

Frequently Asked Questions

Will the migration scripts run as-is in my project?
They are usually close, but treat them as a strong first draft. Set `[migration_tool]` to match your stack, then review naming, defaults, and ordering before running them. Always test generated migrations on a development database before applying them anywhere near production data.
Can it design for databases other than PostgreSQL?
Yes. The `[database_type]` variable lets you target MySQL, SQLite, SQL Server, or others, and the output adapts column types, constraints, and partitioning syntax accordingly. The overall structure stays the same, but database-specific features and limitations will shape the final schema.
Does it handle denormalization, or only strict normalization?
It handles both. Setting `[normal_form]` to something like "3NF with strategic denormalization" prompts it to explain where normalizing helps and where a controlled denormalization improves read performance. It explains the trade-offs so you can decide rather than applying one rule everywhere.
How reliable is the query performance analysis?
It is a reasoned estimate based on your stated `[query_patterns]` and `[large_table]`, not a real benchmark. It points you toward likely bottlenecks and useful indexes, but you should validate with EXPLAIN and real data volumes before treating any performance claim as final.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Data & SQL Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support