agentleFS
jhonatan-oliveiradevjhonatan-oliveiradev/agent-skills/skills/designing-relational-data-models/SKILL.md

designing-relational-data-models

Skill1 starsChanged 3 months agoMITView on GitHub

Use when defining or reviewing a relational data model where entities, ownership, cardinality, lifecycle, constraints, or access patterns need explicit decisions before implementation.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write down the important entities, stable identities, ownership rules, and lifecycle transitions in domain language.

    line 12
  2. Distinctive:

    Add the smallest useful indexes for those access patterns.

    line 17
  3. Distinctive:

    Prefer stable surrogate identifiers when business identifiers can change independently of identity.

    line 21
  4. Distinctive:

    Do not duplicate a fact into several tables without an explicit consistency strategy.

    line 22
  5. Distinctive:

    Do not add nullable columns by default.

    line 23
  6. Distinctive:

    Do not use denormalization as a substitute for measuring a query problem.

    line 24
  7. Distinctive:

    Every proposed index maps to at least one concrete access pattern.

    line 30

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Designing Relational Data Models

Core principle

Model business invariants before tables. A durable relational model makes invalid states difficult to store, keeps relationships explicit, and leaves performance decisions tied to real access patterns rather than guesses.

Workflow

  1. Write down the important entities, stable identities, ownership rules, and lifecycle transitions in domain language.
  2. Define relationship cardinality and deletion behavior explicitly. Distinguish ownership from simple association.
  3. Choose columns from facts the system must preserve. Prefer normalized relational structure for stable, queryable facts; use JSON only when the shape is genuinely variable or opaque to the database.
  4. Encode invariants close to the data with NOT NULL, UNIQUE, foreign keys, and CHECK constraints when PostgreSQL can enforce them safely.
  5. List the concrete reads and writes the product must support before choosing indexes. Include filters, joins, ordering, pagination, and expected selectivity.
  6. Add the smallest useful indexes for those access patterns. Remember that every index adds write, storage, and maintenance cost.
  7. Walk realistic create, update, delete, and concurrency scenarios through the model before implementation.

Decision rules

  • Prefer stable surrogate identifiers when business identifiers can change independently of identity.
  • Do not duplicate a fact into several tables without an explicit consistency strategy.
  • Do not add nullable columns by default. Null should have a defined domain meaning.
  • Do not use denormalization as a substitute for measuring a query problem.
  • Composite index order must follow actual predicate and ordering needs; do not treat multicolumn indexes as generic coverage.

Acceptance checks

  • Invalid domain states are rejected by application logic and, where appropriate, database constraints.
  • Ownership, cardinality, nullability, and deletion semantics are documented.
  • Every proposed index maps to at least one concrete access pattern.
  • Common reads can be expressed without ambiguous ownership or hidden synchronization rules.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.