postgresql-table-design

Design PostgreSQL schemas with normalization, data types, constraints, and indexing.

13|Updated Feb 4, 2026
One-click install
npx skills add https://github.com/abeldotam/bmad-viewer --skill postgresql-table-design-abeldotam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-table-design
Source: https://github.com/abeldotam/bmad-viewer/tree/main/.agents/skills/postgresql-table-design
Command: npx skills add https://github.com/abeldotam/bmad-viewer --skill postgresql-table-design-abeldotam

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL table design guidelines help engineers create robust, scalable schemas by enforcing best practices around normalization, data types, constraints, and indexing.

Core Features & Use Cases

  • Normalize data to 3NF and apply targeted denormalization for performance where appropriate.
  • Choose appropriate data types (TIMESTAMPTZ, BIGINT IDENTITY, TEXT vs VARCHAR) and define constraints (PK, FK, CHECK) to ensure data integrity.
  • Design indexing strategies (PK, FK, partial indexes, expression indexes) and outline common patterns for OLTP and analytical workloads.
  • Use extensions and patterns (JSONB for semi-structured data, timescaledb for time-series, pgcrypto for hashing) when appropriate.
  • Real-world example: Model an orders table with a users FK, product references, and created_at timestamp to illustrate constraints and indexing.

Quick Start

Define a PostgreSQL schema for a simple e-commerce catalog applying the core rules.

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 PostgreSQL tables for scalable data?

Scalable PostgreSQL table design uses BIGINT GENERATED ALWAYS AS IDENTITY primary keys, TIMESTAMPTZ for timestamps, and normalization to 3NF. Apply targeted denormalization, JSONB for semi-structured data, and partitioning to meet OLTP and analytical performance requirements.

What's the best way to choose PostgreSQL data types and constraints for data integrity?

Choose PostgreSQL data types like TIMESTAMPTZ for timestamps and TEXT over VARCHAR for flexible strings. Enforce data integrity by defining primary keys, foreign keys, and CHECK constraints to prevent invalid entries and maintain robust schemas.

How do I create an indexing strategy for PostgreSQL tables?

Create a PostgreSQL indexing strategy by applying primary and foreign key indexes, then adding partial indexes for frequently filtered subsets and expression indexes for computed columns to optimize OLTP and analytical query performance.

When should I use JSONB or arrays in PostgreSQL table design?

Use JSONB in PostgreSQL table design for semi-structured data requiring flexible querying, and use arrays for simple lists. Apply careful, targeted denormalization with these types to avoid overcomplicating normalized 3NF schemas.

Can I use PostgreSQL extensions like timescaledb for specific workloads?

You can use PostgreSQL extensions like timescaledb for time-series workloads and pgcrypto for hashing. Integrate these patterns alongside standard table design to handle specialized analytical and security requirements efficiently.

What are the limitations of normalizing PostgreSQL tables to 3NF?

Normalizing PostgreSQL tables to 3NF ensures data integrity but can introduce join overhead. Limit this by applying targeted denormalization, expression indexes, or partitioning strategies when query performance degrades under heavy OLTP workloads.