Skip to content
timescale avatar

Design Postgres Tables

Opinionated PostgreSQL table-design reference covering data types, constraints, indexing, JSONB, and partitioning.

CCM score
62 of 100
skills.sh installs
685
GitHub stars
1.9K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers data type selection (IDs, numerics, text, time, arrays, ranges, JSONB), constraints, index strategies, and table types
  • Lists PostgreSQL gotchas such as unindexed foreign keys, NULL handling in UNIQUE, silent overflow behavior, and MVCC churn
  • Includes a "do not use" list that steers away from timestamp, char(n), serial, money, and built-in geometric types
  • Designed for schema design and normalization work on reference, OLTP, and update-heavy tables

Install

$ npx -y skills add timescale/pg-aiguide --skill design-postgres-tables -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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”

Details

Repository
github.com/timescale/pg-aiguide
Category
Databases
License
Apache-2.0
First seen
Jun 3, 2026

Questions

What does the design-postgres-tables skill do?

design-postgres-tables is a reference skill for general PostgreSQL table design, covering data types, indexing strategies, constraints, JSONB patterns, partitioning, and row-level security. It guides an agent when creating new tables or modifying existing ones, and when choosing types, constraints or indexes for PostgreSQL.

How do I install the design-postgres-tables skill?

Run npx -y skills add timescale/pg-aiguide --skill design-postgres-tables -y in your project to install it. Once installed, design-postgres-tables lets the agent apply PostgreSQL table design rules when you create or change schemas.

Which category is design-postgres-tables in, and what sets it apart?

design-postgres-tables sits in the Databases category on Claude Marketplaces, alongside supabase-postgres-best-practices and several Prisma skills. Its own scope is general table design, with rules such as preferring BIGINT identity columns, TIMESTAMPTZ for event time, and indexing foreign key columns manually.

Who is design-postgres-tables for?

design-postgres-tables is for developers who design PostgreSQL tables, schemas or data models, including user tables, order tables, reference tables and JSONB schemas. It also suits teams designing update-heavy, upsert-heavy or OLTP-style tables.

More from timescale/pg-aiguide

All 8

Similar to Design Postgres Tables

More Databases