Given an association between a source class A and a destination class B, a Selection path defined on the role to B is an alternative path between the same pair of classes that, given an object of class A, identifies all and only the objects of class B with which it can be associated.
Custom path selector from the
Role menu of the role on which you want to define the Selection path, the Designer shows a number of alternative paths; selecting one, the relationships crossed are highlighted in red. Each step of the path corresponds to the crossing of a relation, and therefore finds a set of objects (the already associated instances of the class towards which the relation points). The set of associated objects are all the instances that can be reached by crossing the path defined in the Selection path.
In the picture are shown the first two Selection path proposed by the Designer for the association role that from Employee enters in Project.
Define a Selection path #
From the Application Schema , right click on a role to open its
Role menu; select
Set selection path... to open the Custom path selector and define the selection path.
A limited number of paths are shown in the
Custom path selector. If the desired path does not appear among those shown, you can define it manually by clicking on the
Define manually...; this command opens a Query path editor, from which you can specify each step of the path in a manner similar to defining a query, without being able to apply filtering conditions and aggregation functions.
To remove a Selection path, right-click on the role on which it was defined to open its
Role menu, and select the
Remove selection path option.
We have modeled an informative system in a position to managing a registry of the employees (Employee) and to trace, for every employee, the center in which it works and the computer that it uses. The system also stores the offices present in each operational location and the distribution of computers in the various offices.
In order to prevent the possibility of assigning to an employee a computer that is not present in the office where he works, we defined a Selection path on the role towards Computer of the association between Employee and Computer (because the assignment of computers to employees is done by the creation/modification mask of the Empoyee class).
We then selected the
Set selection path option from the
Role menu of
computer_: in the following image the Designer shows in red the only alternative path identified by the
Custom path selector:
The selected Selection path (
Employee.branch_.office_.computer) locates the computers that can be associated with a generic employee with the following algorithm that consists of several steps, one for each relationship crossed by the path:
- in the first step, the algorithm identifies the office where the employee works, which will always be only one because the multiplicity of the role pointing to Branch is
- in the second step, for each location identified in the previous step (in this case only one), the algorithm finds all the offices located in that location, which will be in general many because the multiplicity of the role towards Office is
- in the third step, for each office identified in the previous step, the algorithm finds all the computers located in that office, which will be in general many because the multiplicity of the role towards Computer is
(*). The computers thus found at the end of the walk constitute the only instances of the Computer class that it is possible to assign to the employee from which we started.
Given an employee, we can visualize in the following extensional diagram the relationships traversed by the Selection path and the objects found at each step.