Skip to content

■ SKILLS // SKILL SPECS

database-design

Database architecture, schema design, and SQL optimization for production systems

■ [!] ON THIS PAGE ▼
■ INSTALL // npx @self.md/cli install database-design
AuthorSeth Hobson
Namespace@wshobson/claude-code-workflows
Category#data
Version1.2.0
Stars★ 27,261
Downloads↓ 713
Verification[ ✓ ] self.md verified

Database architecture, schema design, and SQL optimization for production systems

Installation

npx claude-plugins install @wshobson/claude-code-workflows/database-design

Contents

Folders: agents, skills

Included Skills

This plugin includes 1 skill definition:

postgresql

Design a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features

View skill definition

PostgreSQL Table Design

Core Rules

  • Define a PRIMARY KEY for reference tables (users, orders, etc.). Not always needed for time-series/event/log data. When used, prefer BIGINT GENERATED ALWAYS AS IDENTITY; use UUID only when global uniqueness/opacity is needed.
  • Normalize first (to 3NF) to eliminate data redundancy and update anomalies; denormalize only for measured, high-ROI reads where join performance is proven problematic. Premature denormalization creates maintenance burden.
  • Add NOT NULL everywhere it’s semantically required; use DEFAULTs for common values.
  • Create indexes for access paths you actually query: PK/unique (auto), FK columns (manual!), frequent filters/sorts, and join keys.
  • Prefer TIMESTAMPTZ for event time; NUMERIC for money; TEXT for strings; BIGINT for integer values, DOUBLE PRECISION for floats (or NUMERIC for exact decimal arithmetic).

PostgreSQL “Gotchas”

  • Identifiers: unquoted → lowercased. Avoid quoted/mixed-case names. Convention: use snake_case for table/column names.
  • Unique + NULLs: UNIQUE allows multiple NULLs. Use UNIQUE (...) NULLS NOT DISTINCT (PG15+) to restrict to one NULL.
  • FK indexes: PostgreSQL does not auto-index FK columns. Add them.
  • No silent coercions: length/precision overflows error out (no truncation). Example: inserting 999 into NUMERIC(2,0) fails with error, unlike some databases that silently truncate or round.
  • **Sequences/

Source

View on GitHub