postgresql-table-design

Designs and reviews PostgreSQL schemas covering data types, indexing, constraints, and partitioning.

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill postgresql-table-design-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-table-design
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/postgresql-table-design
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill postgresql-table-design-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing PostgreSQL schemas without platform-specific knowledge leads to common mistakes like missing foreign key indexes, wrong data types, and poor partitioning choices that hurt performance and maintainability. ## Core Features & Use Cases - Data Type Guidance: Recommends correct PostgreSQL types (TIMESTAMPTZ, NUMERIC, TEXT, JSONB, arrays, ranges) and flags types to avoid like serial, money, and timestamp without time zone. - Indexing & Constraints: Covers B-tree, GIN, GiST, BRIN, partial, covering, and expression indexes plus PK, FK, UNIQUE, CHECK, and EXCLUDE constraint patterns. - Workload-Specific Design: Provides patterns for update-heavy, insert-heavy, and upsert-heavy tables, plus partitioning, row-level security, and safe schema evolution. - Use Case: When creating a new orders table, apply this Skill to get an identity primary key, proper foreign key indexes, CHECK constraints on status values, and TIMESTAMPTZ defaults. ## Quick Start Design a PostgreSQL schema for an orders table with proper data types, indexes, and constraints following best practices.

Frequently Asked Questions about postgresql-table-design

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

FAQPage Schema
How do I design a PostgreSQL table with best practices?

Define a BIGINT GENERATED ALWAYS AS IDENTITY primary key, normalize to 3NF, add NOT NULL and DEFAULT constraints, and index foreign keys and frequent filter columns. Use TIMESTAMPTZ for timestamps, NUMERIC for money, and TEXT for strings.

What data types should I avoid in PostgreSQL?

Avoid timestamp without time zone, char(n), varchar(n), money, timetz, and serial. Use timestamptz, text, numeric, and generated identity columns instead for correct behavior and future-proofing.

Does PostgreSQL automatically index foreign key columns?

No, PostgreSQL does not auto-index foreign key columns. You must create indexes manually on referencing columns to speed up joins and prevent locking issues during parent table deletes or updates.

When should I use JSONB versus regular columns in PostgreSQL?

Keep core relational data in typed columns and use JSONB only for optional or semi-structured attributes. Index JSONB with GIN for containment queries, and extract frequently filtered scalar fields into generated columns with B-tree indexes.

When should I partition a PostgreSQL table?

Partition tables exceeding roughly 100 million rows when queries consistently filter on the partition key, typically time. Use declarative RANGE, LIST, or HASH partitioning, and remember unique constraints must include the partition key.