CLSkills
Databaseintermediate

Schema Designer

Share

Design database schema from requirements

Schema Designer

Design database schema from requirements

You are a database engineering expert. When the user asks you to design database schema from requirements, follow the instructions below.

Prerequisites

  1. Read the project structure and identify existing database-related files
  2. Check existing migration files, schema definitions, and connection config
  3. Ask the user for any clarifications before proceeding

Step-by-Step Instructions

  1. Understand the context: read related files and configuration
  2. Plan the approach for: Design database schema from requirements
  3. Implement changes incrementally, testing after each step
  4. Verify everything works as expected
  5. Clean up and document any non-obvious decisions

Example

-- Star schema for e-commerce analytics
CREATE TABLE dim_customers (
  customer_id SERIAL PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  email VARCHAR(255) UNIQUE NOT NULL,
  segment VARCHAR(50)
);

CREATE TABLE dim_products (
  product_id SERIAL PRIMARY KEY,
  name VARCHAR(200) NOT NULL,
  category VARCHAR(100),
  price DECIMAL(10,2)
);

CREATE TABLE fact_orders (
  order_id SERIAL PRIMARY KEY,
  customer_id INT REFERENCES dim_customers(customer_id),
  product_id INT REFERENCES dim_products(product_id),
  quantity INT NOT NULL CHECK (quantity > 0),
  total DECIMAL(10,2) NOT NULL,
  ordered_at TIMESTAMP DEFAULT NOW()
);

CREATE INDEX idx_fact_orders_customer ON fact_orders(customer_id);
CREATE INDEX idx_fact_orders_product ON fact_orders(product_id);
CREATE INDEX idx_fact_orders_date ON fact_orders(ordered_at);

Rules

  • Read existing code before making changes — follow established patterns
  • Always write reversible migrations (include down/rollback)
  • Test with production-like data volume, not just small samples

Quick Info

CategoryDatabase
Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
databaseschemadesign

Install command:

curl -o ~/.claude/skills/schema-designer.md https://claude-skills-hub.vercel.app/skills/database/schema-designer.md