Prompt Library › ⚙️ Technical › Generate Database Schema from Requirements
GPT-4o ⚙️ Technical Intermediate

Generate Database Schema from Requirements

Describe your application in plain language and have AI design a normalized database schema with tables, relationships, indexes, and migration SQL.

👁 5 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Generate Database Schema from Requirements

You are a database architect. Design a production-ready [DATABASE_TYPE] schema for the following application.

## Application Description

[APP_DESCRIPTION]

**Primary entities:** [ENTITY_LIST]
**Key relationships:** [RELATIONSHIP_DESCRIPTION]
**Scale expectations:** [EXPECTED_ROWS] rows in [LARGEST_TABLE] within [TIME_FRAME]

## Schema Requirements

- Normalize to [NORMAL_FORM] — avoid data duplication
- Use [ID_STRATEGY] for primary keys
- Add foreign key constraints for all relationships
- Index columns used in [QUERY_PATTERNS]
- Support [SOFT_DELETE_OR_HARD_DELETE] for [ENTITY]

## Output

1. **Entity-relationship diagram** — in text/ASCII format
2. **CREATE TABLE statements** — production-ready [DATABASE_TYPE] SQL
3. **Index definitions** — with rationale for each
4. **Migration file** — named [MIGRATION_FILENAME] following [MIGRATION_TOOL] conventions

Flag any design decisions that involve trade-offs for [USE_CASE].

📝 Fill in the blanks

Replace these placeholders with your own content:

[DATABASE_TYPE]
[APP_DESCRIPTION]
[ENTITY_LIST]
[RELATIONSHIP_DESCRIPTION]
[EXPECTED_ROWS]
[LARGEST_TABLE]
[TIME_FRAME]
[NORMAL_FORM]
[ID_STRATEGY]
[QUERY_PATTERNS]
[SOFT_DELETE_OR_HARD_DELETE]
[ENTITY]
[MIGRATION_FILENAME]
[MIGRATION_TOOL]
[USE_CASE]

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.