www.entitylogic.org - entity modelling introduced from first principles
Reference relationships are a second class of relationships and are distinguished from composition relationships by being depicted connecting to the side edges of the boxes representing entity types rather than to the upper and lower edges. Without distinction, connection to the left or right hand side of the boxes can be made; the side can be chosen for the convenience for the drawing. A text label at one end of a relationship line serves to describe the relationship from the point of view of the subject entity at that end. For example, we can say a chicken lays an egg or that an egg is laid by a chicken. Though there is a single relationship between chicken and egg there are two ways of articulating it and accordingly the relationship is shown labelled at each end:
For convenience of the diagramming we can, without changing the meaning, turn this about so:
A chicken hatches from an egg too and we can add this to the diagram like so:
Of course, what we see here represented on the diagram are types of things not actual things - so the diagram does not express that a chicken lays the very same egg that it hatches from: rather that a chicken lays things of the type egg and that it is hatched from a thing of the same type.
The notation introduced for composition relationships has been descriptive of properties of relationships including cardinality and optionality (the crows foot and dashing of lines), exclusion (the exclusion arc) and use of abstraction (nested boxes). These notations apply equally to the representation of reference relationships. A reference relationship can be looped around to relate instances of a single type and it is then said to be recursive. If it is many-one then a hierarchical1 system of entities is implied such as a command hierarchy:
A reference relationship can be looped around to enter the opposite edge with no difference in meaning so the following is equivalent:
Consider also a chain composed of links each connected to the next. Each link of a chain is followed by the next and each link follows at most one other which is to say there is a recursive relationship:
For a more complete model see figure 1.
Some recursive relationships cannot be given a different role at either end for they are symmetric. For example x1 is married to x2 precisely if x2 is married to x1. Marriage is a symmetric binary relationship. When this relationship is shown in an entity model then it must be given the same the name at either end as so:
As a shorthand we can compress this to a single line:
The example in figure 2 illustrates this notation in use.