When you specify a class as the data type of an attribute, you can control its generation to a CDM or PDM using the Generate table, Value Type and Generate ADT (PDM only) options in the Persistent groupbox on the Detail tab.
In the following example, Customer contains an attribute, address, for which the class Address, has been selected as data type (see Specifying a Classifier as a Data Type or Return Type):
Customer is specified as persistent, and the
Generate table option is selected. You can generate the class
Address in any of the following ways:
As a persistent class - by selecting Generate table in the Persistent groupbox on the Detail tab (see Class Properties):
In a PDM, both classes are generated as tables linked by a reference joining the Address ID primary key column (created during generation) in the Address parent table and the address foreign key column in the Customer child table:
|
In a CDM, both classes are generated as entities linked by a one to many relationship joining the Address ID primary identifier (created during generation) in theAddress entity, and the address attribute in the Customer entity:
|
As an embedded class - by selecting Value Type:
In a PDM, Customer is generated as a table with all the attributes of Address embedded in it as columns prefixed by address_:
|
In a CDM, both classes are generated as entities, and Customer includes all the attributes of Address embedded in it as attributes prefixed by address_:
|
As an Abstract Data Type class (PDM only) - by selecting Generate ADT:
In a PDM, Customer is generated as a table and Address is generated as an abstract data type (which does not have a symbol), which is referenced by the column address:
|
Note: If you specify a multiplicity (see
Attribute Properties) for the attribute using a complex data type, when generating:
- A persistent class - the multiplicity is generated as a cardinality on the reference between the tables.
- An embedded class - attributes are generated the maximum number of times required by the multiplicity, but only if the maximum is set to a fixed value. In the following example, attribute multiplicity is 0..2, so attributes will be embedded twice:
- An abstract data type class - for DBMSs that support ARRAY and LIST for abstract data types, multiplicity affects generation as follows:
- 0..n or 1..n - generate as an abstract data type of type LIST (example: TABLE for Oracle).
- 1..2 or 0..10 - generate as an abstract data type of type ARRAY (example: VARRAY for Oracle).
- 0..1 or 1..1 - generate as an abstract data type of type OBJECT.