Creating a New Class Relation

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

This topic describes how to create a parent-child relation between classes in the Data Warehouse.

Note the following information:

  • The classes for the relation and the key for the parent class must exist before creating the relation.

  • The relation name must be unique.

  • Member names in inheritance-type relations should not be duplicated in the parent and child classes because 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 OLE DB provider for Commerce Server.

For information about how to create classes and keys, see Creating a New Class and Creating a New Class Key, respectively.

A class relation is created by creating a new row in the reldef table, populating the columns, and saving the changes. For information about the reldef table, see Reldef Table: Relation Definition Metadata.

The example continues (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. By creating this relation to an existing Data Warehouse class, it is linking to the logical schema. You are not required to link to the existing logical schema when you extend the Data Warehouse.

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

Column name

Column value

Type

R/O

Purpose

RelationName

"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 relation.

Example - Step 6

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

Note

The code in this example is for demonstration only.

'Create an instance in the Relation Definition table.
   recNew.Open "Relation/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
   recNew.Close

Repeat this process 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 that will be used as the foreign key for the OrderFormHeader class. Continue to Creating a New Class Relation Member.

See Also

Other Resources

Extending the Data Warehouse Logical Schema

Creating a New Class Relation Member

Creating a New Class

OrderFormHeader

Reldef Table: Relation Definition Metadata