database-schema-designer

26
5
Source

Design robust, scalable database schemas for SQL and NoSQL databases. Provides normalization guidelines, indexing strategies, migration patterns, constraint design, and performance optimization. Ensures data integrity, query performance, and maintainable data models.

Install

mkdir -p .claude/skills/database-schema-designer && curl -L -o skill.zip "https://mcp.directory/api/skills/download/969" && unzip -o skill.zip -d .claude/skills/database-schema-designer && rm skill.zip

Installs to .claude/skills/database-schema-designer

About this skill

Database Schema Designer

Design production-ready database schemas with best practices built-in.


Quick Start

Just describe your data model:

design a schema for an e-commerce platform with users, products, orders

You'll get a complete SQL schema like:

CREATE TABLE users (
  id BIGINT AUTO_INCREMENT PRIMARY KEY,
  email VARCHAR(255) UNIQUE NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE orders (
  id BIGINT AUTO_INCREMENT PRIMARY KEY,
  user_id BIGINT NOT NULL REFERENCES users(id),
  total DECIMAL(10,2) NOT NULL,
  INDEX idx_orders_user (user_id)
);

What to include in your request:

  • Entities (users, products, orders)
  • Key relationships (users have orders, orders have items)
  • Scale hints (high-traffic, millions of records)
  • Database preference (SQL/NoSQL) - defaults to SQL if not specified

Triggers

TriggerExample
design schema"design a schema for user authentication"
database design"database design for multi-tenant SaaS"
create tables"create tables for a blog system"
schema for"schema for inventory management"
model data"model data for real-time analytics"
I need a database"I need a database for tracking orders"
design NoSQL"design NoSQL schema for product catalog"

Key Terms

TermDefinition
NormalizationOrganizing data to reduce redundancy (1NF → 2NF → 3NF)
3NFThird Normal Form - no transitive dependencies between columns
OLTPOnline Transaction Processing - write-heavy, needs normalization
OLAPOnline Analytical Processing - read-heavy, benefits from denormalization
Foreign Key (FK)Column that references another table's primary key
IndexData structure that speeds up queries (at cost of slower writes)
Access PatternHow your app reads/writes data (queries, joins, filters)
DenormalizationIntentionally duplicating data to speed up reads

Quick Reference

TaskApproachKey Consideration
New schemaNormalize to 3NF firstDomain modeling over UI
SQL vs NoSQLAccess patterns decideRead/write ratio matters
Primary keysINT or UUIDUUID for distributed systems
Foreign keysAlways constrainON DELETE strategy critical
IndexesFKs + WHERE columnsColumn order matters
MigrationsAlways reversibleBackward compatible first

Process Overview

Your Data Requirements
    |
    v
+-----------------------------------------------------+
| Phase 1: ANALYSIS                                   |
| * Identify entities and relationships               |
| * Determine access patterns (read vs write heavy)   |
| * Choose SQL or NoSQL based on requirements         |
+-----------------------------------------------------+
    |
    v
+-----------------------------------------------------+
| Phase 2: DESIGN                                     |
| * Normalize to 3NF (SQL) or embed/reference (NoSQL) |
| * Define primary keys and foreign keys              |
| * Choose appropriate data types                     |
| * Add constraints (UNIQUE, CHECK, NOT NULL)         |
+-----------------------------------------------------+
    |
    v
+-----------------------------------------------------+
| Phase 3: OPTIMIZE                                   |
| * Plan indexing strategy                            |
| * Consider denormalization for read-heavy queries   |
| * Add timestamps (created_at, updated_at)           |
+-----------------------------------------------------+
    |
    v
+-----------------------------------------------------+
| Phase 4: MIGRATE                                    |
| * Generate migration scripts (up + down)            |
| * Ensure backward compatibility                     |
| * Plan zero-downtime deployment                     |
+-----------------------------------------------------+
    |
    v
Production-Ready Schema

Commands

CommandWhen to UseAction
design schema for {domain}Starting freshFull schema generation
normalize {table}Fixing existing tableApply normalization rules
add indexes for {table}Performance issuesGenerate index strategy
migration for {change}Schema evolutionCreate reversible migration
review schemaCode reviewAudit existing schema

Workflow: Start with design schema → iterate with normalize → optimize with add indexes → evolve with migration


Core Principles

PrincipleWHYImplementation
Model the DomainUI changes, domain doesn'tEntity names reflect business concepts
Data Integrity FirstCorruption is costly to fixConstraints at database level
Optimize for Access PatternCan't optimize for bothOLTP: normalized, OLAP: denormalized
Plan for ScaleRetrofitting is painfulIndex strategy + partitioning plan

Anti-Patterns

AvoidWhyInstead
VARCHAR(255) everywhereWastes storage, hides intentSize appropriately per field
FLOAT for moneyRounding errorsDECIMAL(10,2)
Missing FK constraintsOrphaned dataAlways define foreign keys
No indexes on FKsSlow JOINsIndex every foreign key
Storing dates as stringsCan't compare/sortDATE, TIMESTAMP types
SELECT * in queriesFetches unnecessary dataExplicit column lists
Non-reversible migrationsCan't rollbackAlways write DOWN migration
Adding NOT NULL without defaultBreaks existing rowsAdd nullable, backfill, then constrain

Verification Checklist

After designing a schema:

  • Every table has a primary key
  • All relationships have foreign key constraints
  • ON DELETE strategy defined for each FK
  • Indexes exist on all foreign keys
  • Indexes exist on frequently queried columns
  • Appropriate data types (DECIMAL for money, etc.)
  • NOT NULL on required fields
  • UNIQUE constraints where needed
  • CHECK constraints for validation
  • created_at and updated_at timestamps
  • Migration scripts are reversible
  • Tested on staging with production data

<details> <summary><strong>Deep Dive: Normalization (SQL)</strong></summary>

Normal Forms

FormRuleViolation Example
1NFAtomic values, no repeating groupsproduct_ids = '1,2,3'
2NF1NF + no partial dependenciescustomer_name in order_items
3NF2NF + no transitive dependenciescountry derived from postal_code

1st Normal Form (1NF)

-- BAD: Multiple values in column
CREATE TABLE orders (
  id INT PRIMARY KEY,
  product_ids VARCHAR(255)  -- '101,102,103'
);

-- GOOD: Separate table for items
CREATE TABLE orders (
  id INT PRIMARY KEY,
  customer_id INT
);

CREATE TABLE order_items (
  id INT PRIMARY KEY,
  order_id INT REFERENCES orders(id),
  product_id INT
);

2nd Normal Form (2NF)

-- BAD: customer_name depends only on customer_id
CREATE TABLE order_items (
  order_id INT,
  product_id INT,
  customer_name VARCHAR(100),  -- Partial dependency!
  PRIMARY KEY (order_id, product_id)
);

-- GOOD: Customer data in separate table
CREATE TABLE customers (
  id INT PRIMARY KEY,
  name VARCHAR(100)
);

3rd Normal Form (3NF)

-- BAD: country depends on postal_code
CREATE TABLE customers (
  id INT PRIMARY KEY,
  postal_code VARCHAR(10),
  country VARCHAR(50)  -- Transitive dependency!
);

-- GOOD: Separate postal_codes table
CREATE TABLE postal_codes (
  code VARCHAR(10) PRIMARY KEY,
  country VARCHAR(50)
);

When to Denormalize

ScenarioDenormalization Strategy
Read-heavy reportingPre-calculated aggregates
Expensive JOINsCached derived columns
Analytics dashboardsMaterialized views
-- Denormalized for performance
CREATE TABLE orders (
  id INT PRIMARY KEY,
  customer_id INT,
  total_amount DECIMAL(10,2),  -- Calculated
  item_count INT               -- Calculated
);
</details> <details> <summary><strong>Deep Dive: Data Types</strong></summary>

String Types

TypeUse CaseExample
CHAR(n)Fixed lengthState codes, ISO dates
VARCHAR(n)Variable lengthNames, emails
TEXTLong contentArticles, descriptions
-- Good sizing
email VARCHAR(255)
phone VARCHAR(20)
country_code CHAR(2)

Numeric Types

TypeRangeUse Case
TINYINT-128 to 127Age, status codes
SMALLINT-32K to 32KQuantities
INT-2.1B to 2.1BIDs, counts
BIGINTVery largeLarge IDs, timestamps
DECIMAL(p,s)Exact precisionMoney
FLOAT/DOUBLEApproximateScientific data
-- ALWAYS use DECIMAL for money
price DECIMAL(10, 2)  -- $99,999,999.99

-- NEVER use FLOAT for money
price FLOAT  -- Rounding errors!

Date/Time Types

DATE        -- 2025-10-31
TIME        -- 14:30:00
DATETIME    -- 2025-10-31 14:30:00
TIMESTAMP   -- Auto timezone conversion

-- Always store in UTC
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

Boolean

-- PostgreSQL
is_active BOOLEAN DEFAULT TRUE

-- MySQL
is_active TINYINT(1) DEFAULT 1
</details> <details> <summary><strong>Deep Dive: Indexing Strategy</strong></summary>

When to Create Indexes

Always IndexReason
Foreign keysSpeed up JOINs
WHERE clause columnsSpeed up filtering
ORDER BY columnsSpeed up sorting
Unique constraintsEnforced uniqueness
-- Foreign key index
CREATE INDEX idx_orders_customer ON orders(custom

---

*Content truncated.*

software-architecture

davila7

Guide for quality focused software architecture. This skill should be used when users want to write code, design architecture, analyze code, in any case that relates to software development.

463159

scroll-experience

davila7

Expert in building immersive scroll-driven experiences - parallax storytelling, scroll animations, interactive narratives, and cinematic web experiences. Like NY Times interactives, Apple product pages, and award-winning web experiences. Makes websites feel like experiences, not just pages. Use when: scroll animation, parallax, scroll storytelling, interactive story, cinematic website.

12480

planning-with-files

davila7

Implements Manus-style file-based planning for complex tasks. Creates task_plan.md, findings.md, and progress.md. Use when starting complex multi-step tasks, research projects, or any task requiring >5 tool calls.

7863

game-development

davila7

Game development orchestrator. Routes to platform-specific skills based on project needs.

14549

humanizer

davila7

Remove signs of AI-generated writing from text. Use when editing or reviewing text to make it sound more natural and human-written. Based on Wikipedia's comprehensive "Signs of AI writing" guide. Detects and fixes patterns including: inflated symbolism, promotional language, superficial -ing analyses, vague attributions, em dash overuse, rule of three, AI vocabulary words, negative parallelisms, and excessive conjunctive phrases. Credits: Original skill by @blader - https://github.com/blader/humanizer

10048

2d-games

davila7

2D game development principles. Sprites, tilemaps, physics, camera.

12744

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,5541,368

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

1,0791,170

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,4011,103

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

1,174738

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

1,131678

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,274602

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.