5 Working with the OData Model Editor
5.2 Working with the OData Model Element
5.2.7 Creating an Association
This sectoin provides information to create Association between Entities.
An association is a named relationship between two entities. Association defines a peer-to-peer relationship between participating entity types and can support different multiplicities at both the ends. An example of an association is the relationship between the Customer and Order entities.
You can create three types of association:
● Single Association - This is the unidirectional association, which allows navigation in only one direction. See Creating a Single Association [page 44] .
● Bi-directional Association - The bi-directional association allows navigation in both directions of the association. The bi-directional association is defaulted to one-to-many. See Creating a Bidirectional Association [page 47] .
● Self Association - Self association has the ends of the association point to the same entity . See Creating a Self Association [page 48].
5.2.7.1 Creating a Single Association
To define single association proceed as follows:
1. Create entity types as detailed in the Creating an Entity TypeCreating an Entity Type [page 31] section.
2. Select the Single menu under Associations.
Once Single is selected and on moving the mouse pointer into the OData Model Editor, the mouse pointer
changes its shape indicating that the association creation mode in active.
3. Click in the source entity type shape to create an association and drag the mouse to the destination shape.
Once on the destination entity shape, left click the mouse to complete the creation of the association.
The association is created and a dotted arrow line connects the shapes.
4. Choose the Select Icon in the Palette to come out of the association create mode.
○ Press escape from the keyboard to come out of the association create mode.
Note
A Navigation Property is automatically created for the new association. You can rename the navigation property by double clicking on it. Every navigation propery should have a unique name.
The association is created and an arrow with a singe head appears representing the single association. Also the cardinality is displayed on both ends of the arrow implying the relationship one-to-many (star sign represent many).
5. On saving the project, the tree region displays the entity types, new association and the corresponding navigation property.
Note
Association Sets, Referential Constraints and the soruce and target roles are automatically created on creation of an association.
Related Links
Creating a Bidirectional Association [page 47]
Instructions about how to create a bidirectional associations.
Creating a Self Association [page 48]
Explains how to create self associations in the entities.
5.2.7.2 Creating a Bidirectional Association
Instructions about how to create a bidirectional associations.
To create a bidirectional association proceed as follows:
1. Create two entity types as mentioned in the Creating an Entity Type [page 31]section.
2. Select the Bidirectional object under Associations
Once Bidrectional is selected and on moving the mouse pointer into the OData Model Editor, the mouse pointer changes its shape indicating that the association creation mode in active.
3. Click in the source entity type to create a bidrectional association and drag the mouse to the destination entity type.
Note
The destination OData Model Element cannot be a complex type, function import, enum type. The cursor icon changes for invalid destination OData Model Element.
The association is created and a line with an arrow at both the ends connects the shapes.
4. Create multiple birectional association as required.
5. Choose the Select Icon in the Pallete to come out of the association create mode.
○ Press escape from the keyboard to come out of the association create mode.
Note
A Navigation Property is automatically created for the new association. You can rename the navigation property by double clicking on it or by pressing F2. Every navigation propery should have a unique name.
On saving the project, the tree region populates the Entity Types, new Asscociation and the corresponding Navigation Properties.
Related Links
Creating a Single Association [page 44]
Creating a Self Association [page 48]
Explains how to create self associations in the entities.
5.2.7.3 Creating a Self Association
Explains how to create self associations in the entities.
To create a self single/bidirectional association proceed as follows:
1. Create an entity type as mentioned in the Creating an Entity Type Creating an Entity Type [page 31]section.
2. Select Single to create a single self association and select Bidirectional to create a bidirectional self association.
Note
An example for single self association is the association between a Manager and his direct reports. An example for birectional seft association is the association between the Employees and Manager as well as Employees and DirectReports.
3. Double click (click in the entity type shape and drag the mouse inside the entity type. Then click again inside the entity type shape) in the entity type shape to create a single/bidrectional self association.
The self association is created and a dotted arrow line appears.
4. Choose the Select Icon in the Palette to come out of the association create mode.
○ Press escape from the keyboard to come out of the association create mode.
Note
A Navigation Property is automatically created for the new association. You can rename the navigation property by double clicking on it. Every navigation propery should have a unique name.
5. Select the association in the graphical editor.
The properties of the association are displayed in the Properties view.
6. Click in the Value column for the Multiplicity to edit the multiplicity.
7. Select a multiplicity and the OData Model Element displays the changes.
The value for the Role of the association can also be edited in the Properties view.
Related Links
Creating a Single Association [page 44]
Creating a Bidirectional Association [page 47]
Instructions about how to create a bidirectional associations.