Skip to main content Skip to complementary content

Adding complex type elements to entities

Availability-noteDeprecated

About this task

When designing a data model, you can define a complex type with a complete structure which can be reused by elements or entities. After clicking the Design tab in the data model editor, you can check all complex types created in your data model in the Data Model Types area.

Each complex type can serve as the basis for another complex type. You can firstly define a higher level complex type with all common elements; next, define another complex type to extend the higher level complex type and then be extended in turn. For more information, see Data model inheritance and polymorphism.

After creating complex types, you are allowed to make updates on them in the Data Model Types area, and the updates will be synchronized in the elements using them directly.

The following example introduces how to define a complex type AddressType, and then define another two complex types EUAddressType and USAddressType by extending the existing type AddressType to add specific elements to complete the US and EU addresses while inheriting the elements from the main address type.

Procedure

  1. Open the data model editor, and then click the Design tab.
  2. From the Palette, click ComplexType and then click in the Data Model Types area.

    A dialog box pops up.

  3. Enter a name for the complex type and then select the Sequence option in order to list the address elements in the defined order.

    Make sure the name of a complex type does not contain special characters such as, @, #, or -.

  4. Click OK to close the dialog box.

    A new complex type AddressType is displayed in the Data Model Types area. Now you need to add elements to the new complex type.

  5. From the Palette, click TypeElement and then click in the upper part of the complex type which you want to extend.

    The Create Element dialog box pops up.

  6. Select the element type, and then click Next. In this example, select Simple Type.
  7. Enter an element name in the Business Element Name field, select the type from the list, and set the maximum and minimum occurrences.

    In this example, add an element Line1 of string type whose maximum and minimum occurrences are both 1.

  8. Click Finish.

    A new element Line1 is added to the complex type AddressType.

  9. Repeat the procedure to add two other elements: Line2 and City.

What to do next

Now you can extend the AddressType to define the inheritance types for the US and EU addresses. In this example, the EUAddressType extends the main AddressType by adding a postal code and a country, whereas the USAddressType extends the main AddressType by adding a zip code and a state.

  1. From the Palette, click ComplexType and then click in the Data Model Types area.

    A dialog box pops up.

  2. Enter a name for the complex type. In this example, it is EUAddressType.

    Make sure the name of a complex type does not contain special characters such as, @, #, or -.

  3. Select the complex type you want to extend from the list, AddressType in this example.

  4. Click OK.

    The new complex type EUAddressType which extends AddressType is added. Now you can add elements specific to the EUAddressType.

  5. From the Palette, click TypeElement and then click in the upper part of the complex type which you want to add new elements.

    The Create Element dialog box pops up.

  6. Enter a name PostalCode for the new element, select string from the Built-in Type list, and then set both the maximum and minimum occurrences to 1.

  7. Click Finish.

  8. Repeat the procedure to add another new element Country to the complex type EUAddressType.

  9. Follow the same steps to create another complex type USAddressType by extending the existing AddressType. You can add two new elements ZipCode and State which are specific to USAddressType.

Now you can use the complex types when adding elements to entities.

The following example assumes that you have created a new entity Region in the data model DStar and you want to add several new complex type elements to the entity. For more information, see Creating entities in a data model using a graphical designer.

  1. From the Palette, click Element and then click in the upper part of the entity.

    The Create Element dialog box pops up.

  2. Select the Complex Type option, and then click Next.

  3. Enter a name for the new element. In this example, we want to add a complex type element EUAddress first.

  4. Select the complex type from the list, EUAddressType in this example.

  5. Click Finish.

    The new element EUAddress of the complex type EUAddressType is added to the entity, which inherits the elements from AddressType.

  6. Repeat the same procedure to add another new element USAddress of the complex type USAddressType to the entity, which inherits the elements from AddressType.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!