Just as classes have actions that create and delete their objects, so associations have actions that create and delete their instances, called links. Figure 7.7 lists a syntax for several link actions, and several examples are shown in Figure 7.8. Figure 7.7. Syntax for Link ActionsFigure 7.8. Link Action ExamplesAs you would expect, the order of the two object references is immaterial, so the first two statements are equivalent. For clarity, the association end can be included, as illustrated by the third statement. The association end is required to specify the direction of traversal in a reflexive association. The examples in the second block all show traversals. The dagger "points" to the target class, and the square brackets contain the association name. The one after the select statement indicates the target of the traversal is a single instance across an association with multiplicity 1 or 0..1. When the association has a "many" multiplicity (1..* or 0..*), use select many to get the complete set of related instances or select any to get one arbitrary instance. The last statement unrelates two objects by providing object references and the association name. |