← IndexEntry № 029·coding

Design a Normalized Database Schema

Design a fully normalized relational database schema with DDL, indexes, and design rationale.

Optimized for
ClaudeChatGPT
§ When to use this

This prompt asks an AI acting as a database architect to design a normalized relational schema from a feature or system description, returning ready-to-run DDL plus the reasoning behind it. It's most useful at the start of a project or when adding a major feature, when you want a defensible first draft of tables, keys, and indexes rather than evolving the schema ad hoc. The explicit asks for indexes tied to query patterns and for flagged denormalization tradeoffs are what separate this from a naive table dump, forcing the model to justify its decisions.

§ The Prompt— fill in the fields, then copy or open in a tool
§ Customize0/2 fields filled
your prompt — fill the fields above
You are a database architect. Design a normalized relational database schema for [SYSTEM/FEATURE DESCRIPTION]. Provide: (1) all table definitions with column names, data types, and constraints, (2) primary and foreign keys, (3) indexes you'd add for expected query patterns, (4) a brief explanation of normalization decisions. Use SQL DDL syntax compatible with [POSTGRES / MYSQL / SQLITE]. Flag any denormalization tradeoffs.
Open with your prompt →ChatGPTClaudeSends your filled-in prompt straight into a new chat.
§ Example Output

What you can expect back

CREATE TABLE workspaces (
  id BIGSERIAL PRIMARY KEY,
  name TEXT NOT NULL,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE TABLE projects (
  id BIGSERIAL PRIMARY KEY,
  workspace_id BIGINT NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
  name TEXT NOT NULL,
  status TEXT NOT NULL DEFAULT 'active'
);

CREATE TABLE tasks (
  id BIGSERIAL PRIMARY KEY,
  project_id BIGINT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
  title TEXT NOT NULL,
  due_date DATE
);

CREATE TABLE task_assignees (
  task_id BIGINT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
  user_id BIGINT NOT NULL,
  PRIMARY KEY (task_id, user_id)
);

-- Indexes for common filters
CREATE INDEX idx_projects_workspace ON projects(workspace_id);
CREATE INDEX idx_tasks_project_due ON tasks(project_id, due_date);

Notes:
- task_assignees is a junction table to keep the many-to-many in 3NF.
- Denormalization tradeoff: caching a task_count on projects would speed dashboards but risks drift; left out for now.

Illustrative example — your results will vary by tool and inputs.

§ Pro Tips

Get sharper results

  • 01Describe your highest-frequency queries (for example 'list overdue tasks per workspace') so the index recommendations target real access patterns instead of generic guesses.
  • 02Ask the model to call out where it chose 3NF versus a deliberate denormalization, then decide per case rather than accepting either default blindly.
  • 03Specify expected scale (thousands vs. billions of rows) because it changes choices like partitioning, surrogate key types, and whether to index foreign keys.
  • 04Request ON DELETE behavior and uniqueness constraints explicitly, since these are easy for a first draft to omit and painful to retrofit later.
  • 05Have it generate a quick ERD description or Mermaid diagram alongside the DDL so non-DBAs on the team can review the relationships.
§ Variations

Adapt it for your case

Migration from an existing schema

Paste your current tables and ask for a normalized redesign plus the ALTER/migration steps to get there without data loss.

Add soft deletes and auditing

Request deleted_at columns, created_by/updated_by fields, and an audit log table pattern across all entities.

NoSQL / document model

Ask it to instead propose a document schema for MongoDB or DynamoDB and explain the access-pattern-driven denormalization.

Use For — Tasks
Tags#database#schema#sql
§ FAQ

Common questions

Is the generated DDL safe to run as-is?

Treat it as a reviewed-by-human first draft. Validate types, constraints, and cascade behavior against your real requirements before applying it to any environment.

Why does it sometimes recommend denormalization?

Strict normalization can make read-heavy queries slow. The prompt asks it to flag those tradeoffs so you can knowingly cache or duplicate data where performance demands it.

How detailed should my system description be?

The more entities, relationships, and key queries you describe, the better. Vague descriptions produce generic schemas that miss your actual constraints.

§ Related Entries

You may also need