relational-data-modeling
БесплатноБез исполняемых скриптовНе проверенCorrects the wrong defaults a model has when designing a relational schema — the DDL decisions an experienced engineer makes differently. Use when creating or…
от pproenca★ 231 звезда на GitHubОб этом скилле
Relational Data Modeling
The decisions a relational schema forces, and how to settle them so the database enforces what it can and the application is left with only what it must. Every rule names the wrong default it corrects; there is no rule for what a capable model already gets right.
Examples are PostgreSQL 18, and every DDL statement in this skill was
executed against 18.4 — including the failure cases, to confirm the constraints
reject what they claim to reject. Roughly a third of the rules depend on
mechanisms MySQL and SQLite do not have (EXCLUDE, partial unique indexes,
range types, WITHOUT OVERLAPS, deferrable constraints, NOT VALID); those
rules say so. The judgment rules transfer to any relational engine.
When to Apply
Use this skill when:
- Writing or reviewing
CREATE TABLE/ALTER TABLE, a migration, or an ORM schema definition (Prisma, Drizzle, Django models, ActiveRecord, Ecto, SQLAlchemy) - Designing an entity-relationship model, or naming what a row is — the point where key choices become expensive to reverse
- The user says "should this be one table or two", "how do I model many-to-many", "the schema allows bad data", "we need history", "we're adding multi-tenancy", or "can the database enforce this"
- A bug turns out to be a schema that permitted the bad state — duplicates that a unique constraint should have caught, orphans a foreign key should have blocked, overlapping bookings, two rows flagged as default
- Adding constraints to a table that already has rows and traffic
- Reviewing a schema generated by an ORM or a scaffolding tool, which is where polymorphic associations, reflexive surrogate keys, and blanket soft-delete flags arrive from
This skill is NOT for:
- Query tuning, execution plans, or choosing indexes for a read path — this covers only the indexes that constraints and foreign keys require
- Connection pooling, replication, or operational tuning
- Non-relational stores, where the trade-offs it argues from do not hold
Rule Categories
| # | Category | Prefix | Covers |
|---|---|---|---|
| 1 | Identity and Keys | key- |
What a row is; the choice every foreign key depends on |
| 2 | Relationships and Cardinality | rel- |
Keeping references declarable to the database, not just intended |
| 3 | Constraints as the Model | cons- |
Which mechanism can actually hold which invariant |
| 4 | Types and Domains | type- |
The cheapest constraint available, chosen for meaning not habit |
| 5 | Derived and Encoded Data | norm- |
What every deliberate copy costs, and what the database can't see inside |
| 6 | Time, History and Lifecycle | time- |
What happens to a row when the world changes |
Quick Reference
1. Identity and Keys
key-primary-key-is-real-identity— a surrogate hides the natural key; you still owe the table aUNIQUEkey-identity-not-serial—serialis legacy;GENERATED ALWAYS AS IDENTITYblocks the desync that breaks insertskey-uuidv7-for-client-generated— v4 randomises every B-tree insert; useuuidv7(), and only when a UUID is earnedkey-propagate-scoping-key— carry the tenant into child keys so a cross-tenant reference cannot be writtenkey-partition-axis-binds-the-key— for tables that grow with traffic, the partition axis is a key decision, not later tuning
2. Relationships and Cardinality
rel-no-polymorphic-fk—type+idmakes referential integrity undeclarable; use an exclusive arc or a supertyperel-relationship-as-entity— name it if it has facts and a lifecycle; keep it a keyed link table if it doesn'trel-choose-referential-action—CASCADEmeans composition; on a ledger it is data lossrel-index-referencing-side— PostgreSQL does not index the child column; MySQL does, and the habit transfersrel-one-to-one-is-one-table— a split buys a join and enforces nothing unless storage or access control differsrel-subtypes-through-the-key—UNIQUE (id, kind)plus a pinned discriminator proves the variants are disjoint
3. Constraints as the Model
cons-not-null-by-default— aCHECKthat evaluates to NULL passes, andUNIQUEstops constrainingcons-exclude-for-non-overlap— the app-level overlap check is a read-then-write race;EXCLUDEis notcons-partial-unique-index— "at most o
Установить relational-data-modeling в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл relational-data-modeling?
Corrects the wrong defaults a model has when designing a relational schema — the DDL decisions an experienced engineer makes differently. Use when creating or reviewing tables, migrations, ER models, or ORM schema definitions. Covers identity and keys (surrogate vs natural, identity vs serial, uuidv7, composite keys that make cross-tenant references impossible), relationships (polymorphic foreign keys the database cannot enforce, referential actions, unindexed FK columns, disjoint subtypes), invariants the engine can prove instead of application code (EXCLUDE, partial unique indexes, CHECK limits, deferrable cycles, NOT VALID), types (timestamptz, exact money, range types, enum vs lookup table), derived and encoded data (generated columns, JSONB as an escape hatch), and time (events vs in-place updates, soft-delete flags that silently disable constraints, temporal keys). NOT for query tuning, index selection for read paths, or connection pooling.
Как установить скилл relational-data-modeling?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл relational-data-modeling запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic