Skip to content

docs: interlink schema-design concepts; fix PK/entity-integrity examples#216

Merged
dimitri-yatsenko merged 4 commits into
mainfrom
docs/relate-schema-design-concepts
Jul 20, 2026
Merged

docs: interlink schema-design concepts; fix PK/entity-integrity examples#216
dimitri-yatsenko merged 4 commits into
mainfrom
docs/relate-schema-design-concepts

Conversation

@dimitri-yatsenko

Copy link
Copy Markdown
Member

Interlinks the closely-related schema-design concepts — normalization, primary keys, foreign keys / modeling relationships, entity integrity — both conceptually and through mutual cross-references, and fixes two misleading examples. Independent of the v2.3.2 code work (no notebook re-execution); separate from #215.

Content fixes

  • explanation/entity-integrity.md — "Too many key attributes". The example declared (subject_id, timestamp) as "Wrong… destroys entity identity" — but that's a valid per-subject measurement key. Rewrote it to say so, and replaced the example with genuine over-keying (a descriptive attribute — technician — placed in the key). Switched to core types (int32).
  • how-to/design-primary-keys.md — "Keep Keys Small". Added a genuinely-oversized example (varchar(200) where an int32 suffices — the key is copied into every child table, index, and join) and dropped the incorrect # Max 65,535 sessions comment on an int32 field (65,535 is int16's range).

Interlinking (the family was barely connected; normalization.md had no See-also at all)

  • design-primary-keys.mdentity-integrity.md — mutual links; the how-to now states the primary key is how a table enforces entity integrity.
  • normalization.md — new "See also" → entity-integrity, design-primary-keys, model-relationships, relational-workflow-model.
  • entity-integrity.md "See also" → design-primary-keys, model-relationships.
  • relational-workflow-model.md "See also" → the schema-design how-tos.

Notes

Ties together the closely-related schema-design concepts (normalization,
primary keys, foreign keys / modeling relationships, entity integrity) both
conceptually and through mutual See-also links, and corrects two examples.

Content fixes:
- entity-integrity.md 'Too many key attributes': (subject_id, timestamp) is a
  *valid* per-subject measurement key; replace the mischaracterized example with
  genuine over-keying (a descriptive attribute in the key). Use core types.
- design-primary-keys.md 'Keep Keys Small': add a genuinely-oversized example
  (varchar(200) where an int32 suffices) and drop the incorrect 'Max 65,535'
  comment (that is int16's range).

Cross-linking (the family was barely interconnected; normalization had no
See-also at all):
- design-primary-keys <-> entity-integrity: mutual links; state that the primary
  key is how a table enforces entity integrity.
- normalization: new See-also -> entity-integrity, design-primary-keys,
  model-relationships, relational-workflow-model.
- entity-integrity See-also -> design-primary-keys, model-relationships.
- relational-workflow-model See-also -> the schema-design how-tos.
@dimitri-yatsenko dimitri-yatsenko added the documentation Improvements or additions to documentation label Jul 18, 2026
…ity link

- Drop 'Use Fixed-Width for Joins' (a myth — for indexed joins, key type and
  size matter, not fixed vs variable width).
- Drop 'Avoid Dates as Primary Keys' — a date is valid key material for a
  date-identified entity; add a note saying so.
- Add 'Avoid Floating-Point Keys' — float/double equality is unreliable
  (rounding); use decimal or integers.
- Drop 'Avoid Computed Values' — a deterministic, immutable computed key (content
  hash, derived UUID) is fine; immutability is already a stated principle.
- entity-integrity.md: state that entity integrity is largely primary-key design
  and link the Design Primary Keys how-to (bidirectional with the how-to's link
  back).
- entity-integrity.md 'Foreign keys': lead with 'referential integrity is
  impossible without entity integrity — identify unique entities before defining
  relationships,' tying FK -> PK.
- design-primary-keys.md 'Natural Keys': adopt the actionable test — a key is
  natural when it identifies the entity outside the database (printed, written,
  spoken).
Expand normalization.md beyond its workflow-only framing: the three normalization
lenses and their convergence, a classical 1NF/2NF/3NF baseline with functional
dependencies, the Entity Normalization Principle (attributes describe the entity
directly/completely/non-optionally), the e-commerce Order example showing workflow
normalization is stricter than 3NF, the UPDATE-as-design-smell test, and a
tidy-data callout. Preserves the existing mouse/cage worked example and See-also.

Closes #219.
@dimitri-yatsenko
dimitri-yatsenko marked this pull request as ready for review July 18, 2026 19:05

@MilagrosMarin MilagrosMarin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — the interlinking is a real improvement, and both content fixes are correct: the (subject_id, timestamp) example was misleading (that's a valid per-subject measurement key), and the # Max 65,535 sessions comment on int32 was wrong (that's int16's range). Verified all internal links resolve and CI (spelling + linkcheck) passes. New three-lens framing in normalization.md reads well.

Two small observations, not blockers:

  1. design-primary-keys.md drops "Use Fixed-Width for Joins" and "Avoid Computed Values" without a note in the PR body. Both deletions are defensible — the char-vs-varchar guidance is arguably dated (modern InnoDB handles VARCHAR joins fine), and "avoid computed values" would conflict with DJ 2.x's hash-addressed storage as a first-class concept. Just calling it out in case one of them was meant to survive in some form.

  2. The e-commerce example in normalization.md uses dj.Manual for Payment, Shipment, Delivery. Pedagogically these would more naturally be dj.Imported (payment processor / carrier API) or auto-populated by workflow events; dj.Manual glosses over the ingestion mechanism. Minor — the point being made (workflow > 3NF) still lands cleanly.

Approving.

@dimitri-yatsenko
dimitri-yatsenko merged commit d63ab0a into main Jul 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants