Creating a New Class Relation

This section describes how to create a parent-child relation between classes in the Data Warehouse. The classes for the relation and the key for the parent class must exist prior to creating the relation. The relation name must be unique.

Ee823384.note(en-US,CS.10).gifNotes

  • Member names in inheritance type relations should not be duplicated in the parent and child classes since all the parent class members are visible in the child class.

  • For one-to-many relations, the parent key member names should not be duplicated in the child class for the same reason.

  • Two classes should only have one relation defined between them.

  • If the IsPersistent attribute of a class is set to zero (0), and the class is then defined to be a parent class, the value of the IsPersistent attribute of the class is changed to one (1) by the Provider.

A class relation is created by inserting a new instance in the Relation Definition (RelDef) table, populating the attributes, and saving the changes. For information on the Relation Definition table, see Relation Definition Meta-data.

We continue our example (which originated in Creating a New Class) by creating a one-to-many (type 2) relation between the existing OrderGroup class and the 'new' OrderFormHeader class. For details on these classes, see the OrderGroup and OrderFormHeader classes. By creating this relation to an existing Data Warehouse class, we are linking to the logical schema. Linking to the existing logical schema is not necessary for extending the Data Warehouse.

The following table lists the attributes and values in the Relation Definition table for the relation between the OrderGroup and OrderFormHeader classes. Unspecified optional attributes are not shown. In the R/O column, R = required, O = optional.

Attribute Name Attribute Value Type R/O Purpose
RelDefName "OrderGroupToOrderFormHeader" String R Uniquely identifies the relation between the classes.
RelType 2 Integer R Defines the type of relation. The most common is type "2", which is one-to-many.
ParentClassName "OrderGroup" String R Identifies the parent class in the parent-child relation.
ParentClassKey "OrderGroupKey" String R Identifies the key for the parent class.
ChildClassName "OrderFormHeader" String R Identifies the child class in the parent-child relation.
Description "OrderGroup to OrderFormHeader relation." String O Describes the logical concept underlying the relation.

Running Example - Step 6

Create a relation linking the OrderFormHeader class to the OrderGroup class.

'Create an instance in the Relation Definition table.
   recNew.Open "RelDef/OrderGroupToOrderFormHeader", cnnConnection, _
     adModeWrite, adCreateOverwrite

'Set the required attributes
   recNew("ParentClassName") = "OrderGroup"
   recNew("ParentClassKey") = "OrderGroupKey"
   recNew("ChildClassName") = "OrderFormHeader"
   recNew("RelType") = 2
   recNew("Description") = "OrderGroup to OrderFormHeader relation."

'Save the new row.
   recNew("__Commit") = 1
   recNew.Fields.Update

Repeat the process above to add relations between the OrderFormHeader class and other classes (such as the Date class for the existing logical schema). The next step is to create a member relation between specific data members in the parent and child classes to be used as the foreign key for the OrderFormHeader class.


All rights reserved.