Adding complex type elements to entities
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
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.
-
From the Palette, click ComplexType and then click in the Data Model Types area.
A dialog box pops up.
-
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 -.
-
Select the complex type you want to extend from the list, AddressType in this example.
-
Click OK.
The new complex type EUAddressType which extends AddressType is added. Now you can add elements specific to the EUAddressType.
-
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.
-
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.
-
Click Finish.
-
Repeat the procedure to add another new element Country to the complex type EUAddressType.
-
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.
-
From the Palette, click Element and then click in the upper part of the entity.
The Create Element dialog box pops up.
-
Select the Complex Type option, and then click Next.
-
Enter a name for the new element. In this example, we want to add a complex type element EUAddress first.
-
Select the complex type from the list, EUAddressType in this example.
-
Click Finish.
The new element EUAddress of the complex type EUAddressType is added to the entity, which inherits the elements from AddressType.
-
Repeat the same procedure to add another new element USAddress of the complex type USAddressType to the entity, which inherits the elements from AddressType.