postgresql-table-design

Design PostgreSQL schemas with normalization, constraints, and indexing strategies.

52|6|Updated Nov 24, 2025
One-click install
npx skills add https://github.com/ovachiever/droid-tings --skill postgresql-table-design
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-table-design
Source: https://github.com/ovachiever/droid-tings/tree/main/skills/postgresql-table-design
Command: npx skills add https://github.com/ovachiever/droid-tings --skill postgresql-table-design

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a design guide for PostgreSQL schemas emphasizing normalization, appropriate data types, indexing, constraints, and performance considerations to build scalable, maintainable data models.

Core Features & Use Cases

  • Primary keys, normalization to 3NF, and when to denormalize
  • Data types recommendations (TIMESTAMPTZ, NUMERIC, TEXT, BIGINT)
  • Indexing strategies, including FK indexes and expression indexes
  • Constraints, partitioning, and advanced features (JSONB usage, range types)
  • Practical examples for common domains (Users, Orders, Transactions)

Quick Start

Design a new schema with a Users table (BIGINT IDENTITY primary key) and a related Orders table, ensuring proper FK relationships and indexing.

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 schema that scales?

Normalize to third normal form to eliminate redundancy, select appropriate primary keys (BIGINT IDENTITY for most cases, UUID for global uniqueness), apply NOT NULL and UNIQUE constraints, and index foreign keys and frequently queried columns. Denormalize selectively only when read performance justifies it.

What data types should I use in PostgreSQL for different column values?

Use BIGINT for identifiers, TIMESTAMPTZ for time values, NUMERIC for precise decimals, TEXT for strings, and DOUBLE PRECISION for floating-point numbers. PostgreSQL also supports JSONB for semi-structured data and range types for interval storage.

When should I add indexes to a PostgreSQL table?

Index foreign key columns, primary keys (automatic), and columns frequently used in WHERE clauses or JOIN conditions. Consider expression indexes for computed columns and multi-column indexes for common filter combinations; balance read speed against write overhead.

How do I decide between normalization and denormalization in PostgreSQL?

Normalize by default to 3NF to maintain data integrity and reduce storage. Denormalize only for high-ROI read-heavy workloads after profiling; use MVCC awareness and JSONB to store related data without breaking normalization rules.

What constraints should I apply when creating PostgreSQL tables?

Use NOT NULL to enforce required values, PRIMARY KEY for uniqueness and identity, UNIQUE for alternate keys, FOREIGN KEY to maintain referential integrity, and CHECK constraints to enforce domain rules. Constraints prevent invalid data at the database layer.

Does PostgreSQL support advanced schema features like partitioning and array types?

Yes. PostgreSQL supports table partitioning for large datasets, array and domain types for custom data structures, JSONB for flexible semi-structured storage, and range types for interval queries, enabling specialized schema designs for specific workloads.