This is a solid reference for PostgreSQL schema design and migrations, with practical examples for indexing strategies, normalization tradeoffs, and zero-downtime deployments. The code snippets are actually useful, showing things like partial indexes, covering indexes, and the right way to use EXPLAIN ANALYZE. The migration patterns section is probably the most valuable part, walking through the five-step process for changing columns without downtime. It focuses heavily on Postgres with some general SQL principles, so if you're deep in MySQL or NoSQL you'll need to adapt. The query optimization section covers the classics like EXISTS over IN and cursor-based pagination. Good for mid-level developers who know SQL basics but haven't spent years optimizing production databases.

skills.sh installs
394
GitHub stars
1.1K
last updated
Jun 3, 2026

Install

$ npx -y skills add skillcreatorai/ai-agent-skills --skill database-design --agent claude-code

Installs into .claude/skills of the current project.

Files

Database Design

Schema Design Principles

Normalization Guidelines

-- 1NF: Atomic values, no repeating groups
-- 2NF: No partial dependencies on composite keys
-- 3NF: No transitive dependencies

-- Users table (normalized)
CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  email VARCHAR(255) UNIQUE NOT NULL,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Addresses table (separate entity)
CREATE TABLE addresses (
  id SERIAL PRIMARY KEY,
  user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
  street VARCHAR(255),
  city VARCHAR(100),
  country VARCHAR(100),
  is_primary BOOLEAN DEFAULT false
);

Denormalization for Performance

-- When read performance matters more than write consistency
CREATE TABLE order_summaries (
  id SERIAL PRIMARY KEY,
  order_id INTEGER REFERENCES orders(id),
  customer_name VARCHAR(255),  -- Denormalized from customers
  total_amount DECIMAL(10,2),
  item_count INTEGER,
  last_updated TIMESTAMPTZ DEFAULT NOW()
);

Index Design

Common Index Patterns

-- B-tree (default) for equality and range queries
CREATE INDEX idx_users_email ON users(email);

Sponsors

Details

Repository
github.com/skillcreatorai/ai-agent-skills
Categories
Backend & APIs, AI & Agent Building, Design & UI/UX, Databases
First seen
Jun 3, 2026

More from skillcreatorai/ai-agent-skills

All 30
1secondsky avatarcloudflare-mcp-serversecondsky/claude-skillsBuild MCP (Model Context Protocol) servers on Cloudflare Workers with tools, resources, and prompts.388skills.sh installs
2levnikolaevich avatarln-722-backend-generatorlevnikolaevich/claude-code-skillsGenerates .NET Clean Architecture backend structure from entity definitions. Use when bootstrapping .NET backend projects.376skills.sh installs
3bobmatnyc avatarbetter-auth-integrationsbobmatnyc/claude-mpm-skillsBetter Auth framework integrations for TypeScript. Use when wiring route handlers in Next.js, SvelteKit, Remix, Express, Hono, or other web frameworks.363skills.sh installs
4sickn33 avatarcc-skill-backend-patternssickn33/antigravity-awesome-skillsbackend patterns351skills.sh installs
5bobmatnyc avatarphoenix-api-channelsbobmatnyc/claude-mpm-skillsPhoenix controllers, JSON APIs, Channels, and Presence on the BEAM348skills.sh installs
6vercel avatarrouting-middlewarevercel/vercel-pluginrouting middleware338skills.sh installs