Creating a New Class Relation Member

This section describes how to map a member of a parent class to a member of its child class. This allows the mapped parent class member to be seen and populated by the child class. When a class relation is created, the key members from the parent class are automatically mapped to the child class (as a non-key member) but not persisted in the child class. In this example, because the implicitly mapped parent class key is also used as part of the child class key, and all members of a key must be persisted, this behavior must be overridden. Explicitly creating the relation member allows the persistence of the member to be set.

The relation between the classes must already be defined. In addition, the classes must contain the respective data members prior to creating the relation member.

Ee796402.note(en-US,CS.20).gifNote

A relation member is created by creating a new instance of a Relation Member (relmem), populating the attributes, and saving the changes. For information about the Relation Member table, see Relation Member Definition Meta-data.

Our running example (which originated in Creating a New Class) concludes by creating a new relation member mapping the ordergroup_id data members of the OrderFormHeader and OrderGroup classes.

The following table lists the required attributes and values in the Relation Member table for the ordergroup_id member relation. Optional attributes are not shown. In the R/O column, R = required, O = optional.

Attribute name Attribute value Type R/O Purpose
RelationName "OrderGroupToOrderFormHeader " String R Identifies the class relation.
ParentMemName "ordergroup_id" String R Identifies the name of the parent class member.
ChildMemName "ordergroup_id" String R Identifies the name of the child class member.
Description "OrderGroup.ordergroup_id to OrderFormHeader.ordergroup_id relation member." String O Describes the logical concept underlying the relation.

Running Example - Step 7

Create a relation member mapping the ordergroup_id members of the OrderFormHeader and OrderGroup classes and save the updated schema.

Ee796402.note(en-US,CS.20).gifNote

  • The code provided in this example is for demonstration purposes only. The OrderFormHeader class created in this example already exists in the Data Warehouse schema. The CreateSchemaObject.vbs file included in the Commerce Server 2002 Software Development Kit should be used to automate the process of extending the schema. For more information about the script, see Create Schema Object Script.
'Create an instance in the Relation Member Definition table.
   recNew.Open _
   "RelMember/OrderGroupToOrderFormHeader/ordergroup_id/ordergroup_id", _
    cnnConnection, adModeWrite, adCreateOverwrite

'Set the attributes.
   recNew("ParentMemName") = "ordergroup_id"
   recNew("ChildMemName") = "ordergroup_id"
   recNew("Description") = "OrderGroup.ordergroup_id to " & _
    "OrderFormHeader.ordergroup_id relation member."

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

'Commit the changes to the Data Warehouse schema.
   cmdCommand.CommandText = "CommitSchema"
   cmdCommand.Execute

'Turn off "Schema Change" mode.
'If SchemaMode is set to a value other than On, True, or 1
' it is turned off. 
   cmdCommand.CommandText = "SchemaMode=0"
   cmdCommand.Execute

'Close the connection.
   cnnConnection.Close

'Release the objects.
   Set recNew = Nothing
   Set cmdCommand = Nothing
   Set cnnConnection = Nothing

This completes the example of extending the Data Warehouse to include the OrderFormHeader class.

If the OrderFormHeader class was not a pre-existing Data Warehouse class, custom log import tasks would have to be created to populate the new class with user data. Additionally, custom calculations would have to be created to access the new structures for reporting.

See Also

Create Schema Object Script

Copyright © 2005 Microsoft Corporation.
All rights reserved.