jonnify·bcs /bcs/elixir-core/relations/a-relation-is-a-system

B2.5.1 · dive 1 of 3 · module B2.5

A relation is a system.

An edge is its own owning process, keyed by the tuple {subject, object} — not a list embedded in either endpoint. Player-in-room is a store, not a field on a player or a room.

A relation as a row keyed by the tuple, owned by one process; neither endpoint carries it. Select a part.
subject entityno rooms: [...] fieldobject entityno players: [...] field EdgeStore (one owner)one kind of edge {subject, object} → propsthe relation is the row
readout · Select a part. An edge is one owning GenServer for one kind of edge; the edge is a row keyed {subject, object}; neither endpoint carries a list of the other.
§1

The idea

echo_data · bcs/edge_store.ex

A relation is not a field on either thing it relates; it is a system of its own. EchoData.Bcs.EdgeStore is one owning process for one kind of edge, and the edge is a row keyed by the tuple of names — {subject, object} — carrying its own properties. Portfolio holds asset, player in room: a row in a store, not a list embedded in the portfolio or the room.

Keeping the relation outside both endpoints is what keeps the endpoints clean. A subject does not grow a list of its objects and an object does not grow a list of its subjects; neither has to be rewritten when a membership changes, and neither can drift out of step with the other. The single fact — this subject relates to this object — lives in one place, owned by one process.

Codemojex makes each relationship its own store. Player-in-room is one EdgeStore, tile-ownership another; a room crashing does not touch the ownership graph, and a new kind of relation is a new supervised store rather than a new field threaded through every entity. A relation is a system, supervised and addressed like any other.

§4

The doors

the sibling courses
§2

References

sources · related

Sources

Related