postgresql-fundamentals

Master PostgreSQL SQL fundamentals - data types, tables, constraints, schema design

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "postgresql-fundamentals" with this command: npx skills add pluginagentmarketplace/custom-plugin-postgresql/pluginagentmarketplace-custom-plugin-postgresql-postgresql-fundamentals

PostgreSQL Fundamentals Skill

Atomic skill for SQL foundations and schema design

Overview

Production-ready patterns for PostgreSQL 16+ data modeling, including type selection, constraint design, and schema organization.

Prerequisites

  • PostgreSQL 16+ installed
  • Basic SQL knowledge
  • Database access with CREATE privileges

Parameters

parameters:
  operation:
    type: string
    required: true
    enum: [create_table, add_constraint, select_type, design_schema]
  table_name:
    type: string
    pattern: "^[a-z][a-z0-9_]*$"
  schema:
    type: string
    default: "public"

Quick Reference

Data Type Selection

Use CaseRecommendedAvoid
Primary keyBIGINT GENERATED ALWAYS AS IDENTITYSERIAL
MonetaryNUMERIC(19,4)FLOAT
TimestampsTIMESTAMPTZTIMESTAMP
UUIDUUIDVARCHAR(36)
JSON dataJSONBJSON

Table Template

CREATE TABLE schema_name.table_name (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

Constraint Patterns

-- Foreign key
CONSTRAINT fk_name FOREIGN KEY (col) REFERENCES other(id) ON DELETE CASCADE;
-- Check
CONSTRAINT chk_positive CHECK (amount > 0);
-- Unique
CONSTRAINT uq_email UNIQUE (email);

Validation Rules

RulePattern
Table names^[a-z][a-z0-9_]{2,62}$
Column names^[a-z][a-z0-9_]{1,62}$

Test Template

DO $$ BEGIN
    DROP TABLE IF EXISTS test_users;
    CREATE TABLE test_users (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY);
    ASSERT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'test_users');
    DROP TABLE test_users;
END $$;

Troubleshooting

ErrorCauseSolution
42P07Table existsUse IF NOT EXISTS
23505Duplicate keyCheck constraints
42703Column not foundVerify names

Usage

Skill("postgresql-fundamentals")

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

postgresql-advanced-queries

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

postgresql-plpgsql

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

java-spring-boot

No summary provided by upstream source.

Repository SourceNeeds Review