Prompt Library ⚙️ Technical Write a Database Schema from Business Requirements
GPT-4o ⚙️ Technical Intermediate

Write a Database Schema from Business Requirements

Design a normalized, production-ready database schema from plain business requirements — including tables, relationships, indexes, and constraints.

👁 5 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Write a Database Schema from Business Requirements

You are a senior data architect who designs schemas that are easy to query and hard to corrupt.

## Business Requirements

Application domain: [DOMAIN]
Database: [DATABASE_TYPE]
Scale: [EXPECTED_ROWS] rows in the largest tables, [CONCURRENT_USERS] concurrent users

Core entities and relationships:
1. [ENTITY_1]: [DESCRIPTION]
2. [ENTITY_2]: [DESCRIPTION]
3. [ENTITY_3]: [DESCRIPTION]
4. [ENTITY_4]: [DESCRIPTION]

Key business rules:
- [BUSINESS_RULE_1]
- [BUSINESS_RULE_2]
- [BUSINESS_RULE_3]

## Schema Design

**Normalization analysis**
Identify any denormalization trade-offs worth making for [EXPECTED_ROWS] query patterns.

**Complete schema:**

```sql
[FULL CREATE TABLE STATEMENTS]
```

Include for each table:
- All columns with appropriate types for [DATABASE_TYPE]
- Primary keys (prefer surrogate keys)
- Foreign key constraints with cascade rules
- NOT NULL and DEFAULT constraints
- CHECK constraints for [BUSINESS_RULE_1] and [BUSINESS_RULE_2]
- Unique constraints

**Indexes:**
Write CREATE INDEX statements for the most common query patterns in [DOMAIN]. Explain the reasoning for each.

**Audit fields:**
Add created_at, updated_at, and any soft-delete fields appropriate for [DOMAIN].

## Common Queries

Write 3 example queries that the application will run frequently, showing the schema in action.

## Migration Safety

Note any fields that would be dangerous to add or remove after data is in production.

📝 Fill in the blanks

Replace these placeholders with your own content:

[DOMAIN]
[DATABASE_TYPE]
[EXPECTED_ROWS]
[CONCURRENT_USERS]
[ENTITY_1]
[DESCRIPTION]
[ENTITY_2]
[ENTITY_3]
[ENTITY_4]
[BUSINESS_RULE_1]
[BUSINESS_RULE_2]
[BUSINESS_RULE_3]
[FULL CREATE TABLE STATEMENTS]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into GPT-4o

Open your preferred AI assistant and paste the prompt to get started.