Show TOC

Associations (CDS)Locate this document in the navigation structure

Associations define relationships between entities.

Procedure

  1. Select the Association tool in the CDS toolbox and draw a link from the child to the parent entity. SAP PowerDesigner adds a new attribute with the name of the parent entity to the child entity and sets its data type to Association to <parent entity>.
  2. Double-click the association link to open its property sheet and click the Joins tab to specify additional properties.

    You can specify either a managed or unmanaged association.

    In this example, the six Address elements are created through managed associations drawn from the Person entity to the Address entity (which uses the StreetAddress and CountryAddress structured types):

    Association Type/Steps

    Join Properties/Generated Code

    [default] Implicitly use the target entity's primary key as foreign key.



    Code:
    Address_1: Association to Address;

    To explicitly specify the target entity's primary key (e.g. id), as the foreign key, select it in the Parent Table Column column.



    Code:
    Address_2: Association to Address { id };

    To specify one or more other elements from the target entity as foreign key elements, select them (e.g. zipcode, street, and country) in the Parent Table Column column.



    Code:
    Address_3: Association[1] to Address { zipCode, street, country };

    To specify a cardinality for the association (e.g. 0..*), select or enter it in the CDS Cardinality field.



    Code:
    Address_4: Association[0..*] to Address { zipCode };

    To specify sub-elements from structured types as foreign key elements, enter them manually (e.g. street.name in the Sub-Element column.



    Code:
    Address_5: Association[*] to Address { street.name };

    To specify an alias for any of the foreign key elements, enter it in the Alias column.



    Code:
    Address_6: Association[*] to Address { street.name as streetName, 
    country.name as countryName };
    In this example, the inhabitants element is defined by an unmanaged association, drawn from the Person entity to the Address entity:

    Association Type/Steps

    Join Properties/Generated Code

    • Select the Unmanaged association checkbox.
    • Select an element from the target entity in the Parent Table Column column.
    • Select an element from the source entity in the Child Table Column column.
    • [optional] Specify a cardinality.



    Code:
    inhabitants: Association[*] to Employee on id = inhabitants.officeId;
  3. Click OK to complete the creation of the association.