Skip to content

Schema: subtype / generalization (is-a) relationships between entities #8

Description

@jbeda

The gap

A relationship is {entity, cardinality, role, ownership, note}. There is no way to say one entity is a kind of another. Generalization is a bread-and-butter domain-modeling construct, and models hit it early.

Motivating example, from modeling a diagram tool's scene graph. The model has a Node entity and four kinds of node:

Node:
  definition: >-
    Any element of the scene tree. Every `Node` is exactly one of
    `Container`, `Shape`, `Arrow`, or `Label`. ...
  invariants:
    - id: node-unique-id
      statement: A `Node` id is unique within its `Scene`.
Container:
  definition: A `Node` that establishes a local coordinate frame ...
Shape:
  definition: A leaf `Node` with visible geometry ...

The "is a kind of" claim lives only in definition prose. Three costs:

  1. The rendered ER diagram cannot draw the subtype fan. Shape and Node appear unrelated.
  2. Invariants declared on Node (unique id, single parent) do not formally bind to Container, Shape, Arrow, or Label.
  3. The linter cannot check the enumeration: nothing verifies the listed kinds all exist, or flags a fifth entity whose prose claims to be a Node but was never listed.

Possible shape

A subtypeOf: Node field on the entity (or a subtypes: [...] list on the parent, mirroring the declare-from-the-parent convention for relationships). Lint checks that fit the existing style: warn when a backticked "is a X" phrase appears in a definition with no declared subtype link; render the fan in the ER output; treat parent-entity invariants as covering subtypes for the completeness checks.

Workaround today

Prose in the parent entity's definition, repeated per kind, with none of it checkable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions