
An Association is a named relationship between two or more 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. The Service Builder provides the facility to create and edit Associations. This document guides you to create an association in the Service Builder.
Creating an Association
You can create an association in one of two ways:
Using the Association Wizard
Use the Association wizard to quickly define the following for a data model:
Associations
Association Sets
Referential Constraints
Navigation Properties
Using the Mass Edit View
Create and edit the different individual artifacts needed for an association using the mass edit view for the data model.
You can quickly define a minimum set of information for an association using the association wizard, and enhance it using the mass edit view.
Make sure that you are working in the edit mode.
Using the Association Wizard
To create an association using the wizard:
Right click the data model folder in your project, and choose Create, and then choose Association.
Alternatively, right click Associations in the data model folder and choose Create.
The Association wizard displays.
Specify the following in the Create Association page of the wizard:
Association name
Specifies a name for the new association.
An error message displays if you do not specify a name, or if the name contains a character that is not allowed.
Below this field, there are the following areas:
Principal Entity
The Principal Entity represents the leading end of the association.
Entity Type Name
Specifies the name of the entity type for the new association. The entity at this end of the association can exist independently of the entity on the dependent end of the association.
Press F4 to select the entity type.
Cardinality
Specifies the relations between the specified principal entity type and the dependent entity type.
Press F4 or click to select from the list. The multiplicity of the association can be as follows:
0: 0..1
Only one instance occurs, zero is also allowed.
1
One-to-one relations. Exactly one instance occurs.
M: 1..n
One-to-many relations. One or more instances can occur.
N: 0..n
Zero-to-many relations. Zero or more instances can occur.
Many-to-many relations is not supported in the wizard.
Create related navigation property
Optional. Select this option to set a link for the entity type.
Under Principal Entity, when selected the navigation property name is proposed based on the specified cardinality.
Under Dependent Entity, when selected the navigation property name is proposed based on the specified cardinality.
Navigation Property
Available only when the option to create a related navigation property is selected.
It sets a navigation property name for the specified entity type. The name is proposed based on the cardinality of the entity.
Dependent Entity
The Dependent Entity represents the secondary part of the association.
Entity Type Name
Specifies the name of the entity type defined as the related entity in the new association.
Press F4 to select the entity type.
The entity at this part of the association exists only if an entity type has been defined for the Principal Entity
Cardinality
Specifies the relations between the specified dependent entity type and the principal entity type.
Press F4 or click to select from the list. The multiplicity of the association can be as defined in the principal part of the association:
Create related navigation property
Optional. Select this option to set a link for the entity type.
Under Dependent Entity, when selected the navigation property name is proposed based on the specified cardinality.
Navigation Property
Available only when the option to create a related navigation property is selected.
It sets a navigation property name for the specified entity type. The name is proposed based on the cardinality of the entity.
Click Next to define referential constraints.
The principal part of the referential constraint contains one or more property elements that name the key properties of the principal entity type.
To make changes in the previous wizard page, click Back.
Specify the following for the referential constraints; you can relate each key of the principal entity type to a property of the dependent entity type:
Principal key
Press F4 to select a key property in the principal entity type.
Dependent property:
Press F4 to select a property in the specified dependent entity type.
Click Next to define a name for the association sets, or the collection of associations in each entity type.
Press F4 to select the entity set for the specified entity type.
Click Finish.
The wizard creates an entity object that contains the collection of association set, the Entity Set, and the Navigation Properties for the defined Association.
Using the Mass Edit View
To create an association using the mass edit view. proceed as follows:
Expand the Data Model folder in the tree view of your project
.
Choose
Edit
for edit mode.
Double-click the Association folder to open it in the mass edit view.
Choose
Edit
and then
Insert Row
to create a new association.
A row is now added.
Do the following in the mass edit view under Associations:
|
Fields |
Description |
|---|---|
|
Name |
Enter a name for the new association in this field. Note
An error message displays if you do not enter a name for the association. |
|
External Association |
Click to create an external association. The term external association refers to creating an association with the entities of the model that has been included in the Service Builder. See Including an OData Service for more information. |
|
Principal Entity |
Enter the name of the Principal Entity, the entity which is being considered for the From Role in the new association. |
|
Principle Entity Cardinality |
Select a cardinality for the Principal Entity from the drop-down list. |
|
Dependent Entity |
Enter the name of the Dependent Entity, the entity which is being considered for the To Role in the new association. |
|
Dependent Entity Cardinality |
Select a cardinality of the Dependent Entity from the drop-down list. |
|
Label |
Enter a label for the new association. This label is displayed as the label when the service is consumed. |
|
Label Text Reference Editor |
To define the label, use the Label Text Reference Editor. The Label Text Reference Editor enables you to enter the reference type. |
In the mass edit view, you can display the details of the association at any time by selecting the relevant row and choosing Details
. A popup is displayed,
which lists the group descriptions and corresponding cell content. The information displayed in this popup is read-only.
You can also use additional functions available in the mass edit view as described in the table below:
|
Icons |
Description |
|---|---|
|
|
Click to insert a row as required to add an association |
|
|
Click to delete a row |
|
|
Click to sort the list in ascending order |
|
|
Click to sort the list in the descending order |
|
|
Click to change the existing layout |
|
|
Click to hide and unhide the tree view |
Click
to save the association.
The new Association will appear under the Associations folder in the tree view.
Generated services based on BOR and RFC data sources in the Service Builder support navigation between entities within the same service, and between entities in different services.
To properly handle associations for data sources, make sure that the following is met:
A referential constraint has been created to define a foreign key relation.
A navigation property is created for the principal entity.
Navigation from a dependent entity to a principal entity is not supported by the generating mechanism for BOR and RFC data sources.