← ClaudeAtlas

postgres-schema-designlisted

Design and review PostgreSQL tables/schemas. Covers data modeling (entities·relationships·normalization), identifier strategy (natural/surrogate keys), constraints·integrity (PK/FK/UNIQUE/CHECK), type selection, history modeling, and naming conventions. Use when writing new table/migration DDL or reviewing an existing schema. Applies the principles of "Core Data Modeling," validated against the official PostgreSQL documentation.
ch4570/vulpora · ★ 1 · API & Backend · score 67
Install: claude install-skill ch4570/vulpora
# PostgreSQL Schema Design Official PostgreSQL `Data Definition`/`Constraints` documentation + data modeling insight. See `reference/principles.md` for the underlying principles. ## Design/review order 1. **Identify what the data represents** (entities/relationships/attributes). Spot concepts from receipts, screens, and requirements. 2. **Apply data modeling principles** — `reference/kb/data-modeling.md`. 3. **Design integrity/constraints** — `reference/kb/constraints-integrity.md`. 4. **If history is needed**, choose a history model — `reference/kb/history-modeling.md`. 5. **Check naming conventions** — `reference/kb/naming-standards.md`. 6. Present the DDL, and for a change also review safety with the **risk-check skill**. ## Quick checklist (HIGH-and-above candidates) ### Integrity (most important — non-negotiable) - [ ] **Does every table have a PK.** - [ ] **Is NOT NULL the default.** Allow NULL only for genuinely optional columns. - [ ] **Does every relationship have an FK.** Does the `ON DELETE` behavior match the meaning (CASCADE/RESTRICT/SET NULL). - [ ] **Is there an index on the FK column.** PG does not create one automatically → full scan on parent DELETE/UPDATE. - [ ] **Does the natural key (business uniqueness) have a UNIQUE constraint.** Relying only on a surrogate key lets duplicates pile up. - [ ] **Are domain rules enforced with CHECK** (`amount >= 0`, status value sets, period `start <= end`). ### Types - [ ] Money is `numeric` (no floating point). Id