database-design-patterns

Identify and resolve database schema design inefficiencies across PostgreSQL, MySQL, and SQL workloads.

Updated Sep 8, 2025
One-click install
npx skills add https://github.com/randalmurphal/claude-config --skill database-design-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-design-patterns
Source: https://github.com/randalmurphal/claude-config/tree/main/skills/database-design-patterns
Command: npx skills add https://github.com/randalmurphal/claude-config --skill database-design-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Database schema design including normalization, denormalization, indexes, migrations, foreign keys, constraints, and query optimization. Use when designing database schemas, optimizing queries, setting up migrations, or debugging performance issues.

Core Features & Use Cases

  • Normalization Principles: 1NF/2NF/3NF guidance.
  • Denormalization Tradeoffs: When to denormalize for read performance.
  • Indexes & Constraints: Effective indexing and data integrity.

Quick Start

Normalize schema first, then introduce denormalized elements only after performance measurement.

Frequently Asked Questions about database-design-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I normalize a database schema to reduce redundancy?

Normalization organizes data into 1NF, 2NF, and 3NF to eliminate redundancy and improve data integrity. Start by identifying repeating groups and separating them into distinct tables, then remove partial dependencies by ensuring non-key attributes depend on the entire primary key, and finally eliminate transitive dependencies between non-key attributes.

When should I denormalize a database schema for better performance?

Denormalize only after measuring performance and identifying read bottlenecks that normalization cannot solve through indexing alone. Strategic denormalization—such as storing computed values or duplicating data across tables—trades write complexity and storage for faster queries; apply it selectively where query load justifies the tradeoff.

What indexing strategy works best for query optimization in SQL?

Index frequently queried columns, foreign keys, and WHERE clause predicates to accelerate searches. Avoid over-indexing write-heavy tables; use composite indexes for multi-column filters and monitor query execution plans to identify missing or unused indexes on PostgreSQL, MySQL, and other SQL workloads.

How do I plan and execute reversible database migrations safely?

Write migrations as paired forward and rollback scripts that preserve data integrity and schema state. Test migrations on production-like data volumes, document schema changes, and ensure each migration is independent and idempotent so you can reverse failed deployments without data loss.

Can I apply database design patterns to existing schemas without rebuilding?

Yes. Analyze your current schema for inefficiencies, apply constraints and foreign keys incrementally, add indexes without downtime, and use migrations to refactor tables. Start with read-heavy optimization through indexing, then introduce denormalization or structural changes only where measurement shows benefit.

What constraints and data types prevent schema design problems?

Use NOT NULL, UNIQUE, PRIMARY KEY, and FOREIGN KEY constraints to enforce data integrity at the database layer. Choose appropriate data types to match domain requirements and prevent invalid data entry; combine constraints with migrations to retrofit enforcement onto existing schemas progressively.