Relationships — Concept

A relationship is a typed edge from one entity instance to another. Causet manages the edge store; you declare the shape and optionally wire emit_events so projections can materialize queryable join tables.


Why relationships exist

Not every connection between entities belongs on a single entity’s snapshot. A user follows dozens of artists — storing following: [] on the user works, but so does a first-class edge with uniqueness enforced by the engine.

Relationships give you:

  • Engine-level uniquenessunique: true deduplicates (from_id, to_id) at storage time
  • Optional automatic eventsemit_events.created / removed without a separate op: emit
  • Cross-stream writes in corerelationship_create is allowed in core (unlike mutating another entity’s fields)

Relationships vs entity state vs projections

MechanismBest for
Entity state (push on /following)Small lists owned by one entity
RelationshipGraph edges with cardinality and uniqueness
ProjectionQueryable read models (join tables, feeds)

Typical pattern: relationship + emit_events → projection listens to those events → query joins projection tables.


Cardinality mental model

  • many_to_many — users follow artists; artists have many followers
  • one_to_many — one owner, many owned records (each to has at most one from)

Next steps