Show TOC

AssociationsLocate this document in the navigation structure

Concept

An Association is a named relationship between two or more entities. The 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 Service Builder.

Creating an Association

You can create an association in one of the 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 define a minimum set of information for an association using the association wizard, and enhance it using the mass edit view.

Note

Make sure that you are working in the edit mode.

Using the Association Wizard

To create an association using the wizard:

  1. Right click the data model folder in your project, and click Create, and then click Association. Alternatively, right click Associations in the data model folder and click Create.

    The Association wizard displays.

  2. Specify the following in the Create Association page of the wizard:

    • Association name

      Specifiy 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:

      1. 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 independent of the entity on the dependent end of the association.

          Press F4 to select the entity type.

        • Cardinality: specifies the relation 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 relation. Exactly one instance occurs.

          • M: 1..n - One-to-many relation. One or more instances can occur.

          • N: 0..n - Zero-to-many relation. Zero or more instances can occur.

            Note

            Many-to-many relation is not supported in the wizard.

        • Create related navigation property

          Optional. Select this option to set a link for the entity type. When selected, the navigation property name is proposed based on the specified cardinality.

        • Navigation Property

          Available only when 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. If navigation property is created under Principal Entity, it sets a navigation link from the Principal Entity Type to the Dependent Entity Type.

      2. Dependent Entity

        • 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. When selected, the navigation property name is proposed based on the specified cardinality.

        • Navigation Property

          Available only when 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. If navigation property is created under Dependent Entity, it sets a navigation link from the Dependent Entity Type to the Principal Entity Type.

  3. 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.

  4. 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.

  5. 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.

  6. 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:

  1. Expand the Data Model folder in the tree view of your project. Click Display<-->Change for edit mode.

  2. Double-click the Association folder to open it in the mass edit view.

  3. Click Insert Row to create a new association.

    A row is now added.

  4. 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 Editor

    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 a SAP Gateway 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.

  5. You can also use additional functions available in the mass edit view as described in the table below:

    Icons

    Description

    Insert Row

    Click to insert a row as required to add an association

    Delete Row

    Click to delete a row

    Sort Ascending

    Click to sort the list in ascending order

    Sort Descending

    Click to sort the list in the descending order

    Change Layout

    Click to change the existing layout

    Show/Hide Tree View

    Click to hide and unhide the tree view

  6. Click Save to save the association.

    The new Association will appear under the Associations folder in the tree view.

Note

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 for the association.

  • A navigation property is created in the relevant entity.