postgresql-table-design

Designs PostgreSQL table schemas including keys, indexes, and constraints.

Updated Apr 25, 2026
One-click install
npx skills add https://github.com/tomasbasso/SistemaStockV2 --skill postgresql-table-design-tomasbasso
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-table-design
Source: https://github.com/tomasbasso/SistemaStockV2/tree/main/.agents/skills/diseno-base-de-datos-postgresql
Command: npx skills add https://github.com/tomasbasso/SistemaStockV2 --skill postgresql-table-design-tomasbasso

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL table design often suffers from poor normalization, insufficient constraints, and non-optimized indexing, leading to data integrity issues and slow queries. This Skill provides a structured approach to create robust schemas that scale with business requirements, emphasizing primary keys, data types, constraints, and performance patterns.

Core Features & Use Cases

  • Primary key design and identity generation: Choose BIGINT GENERATED ALWAYS AS IDENTITY or UUID when global uniqueness is needed.
  • Normalization and when to denormalize: Aim for 3NF and only denormalize when justified by read performance.
  • Indexing strategies: Create PK, FK, and frequently filtered column indexes; use partial or expression indexes where beneficial.
  • Data types and constraints: Recommend TIMESTAMPTZ, NUMERIC for money, TEXT for strings, and ensure NOT NULL with CHECK constraints.
  • Use Case: Designing tables for users, orders, and audit logs with stable schemas.
  • These are examples; real-world schemas will vary.

Quick Start

Design your first PostgreSQL schema for a new app using these guidelines.

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 schema for scalable apps?

Designing PostgreSQL schemas for scalable apps requires structuring tables with BIGINT identity primary keys, TIMESTAMPTZ for dates, and proper normalization. This approach ensures data integrity and query performance as your application grows.

When should I use UUID vs BIGINT identity for PostgreSQL primary keys?

Use BIGINT GENERATED ALWAYS AS IDENTITY for standard sequential primary keys, but choose UUID when global uniqueness across distributed systems is required. Both approaches maintain data integrity while serving different scaling requirements.

What are the best PostgreSQL data types for money and timestamps?

The best PostgreSQL data types for money and timestamps are NUMERIC for financial values to ensure precision, and TIMESTAMPTZ for timestamps to handle timezone conversions correctly across your application.

How do I optimize PostgreSQL indexing for foreign keys?

Optimize PostgreSQL indexing for foreign keys by creating indexes on all primary keys, foreign keys, and frequently filtered columns. Use partial or expression indexes where beneficial to improve query performance.

When should I denormalize a PostgreSQL database schema?

Denormalize a PostgreSQL database schema only when justified by read performance requirements, after first aiming for Third Normal Form (3NF). Proper normalization prevents data anomalies while targeted denormalization optimizes queries.

Does PostgreSQL schema design require NOT NULL and CHECK constraints?

PostgreSQL schema design requires NOT NULL and CHECK constraints to enforce data integrity at the database level. Applying these constraints ensures invalid data is rejected before insertion, preventing application errors.