Creating a New Class Key Member

This topic describes how to define class member(s) to form an explicit single- or multi-membered key for a class. The class for the key member(s) must already exist with a defined class key. The class must already contain the indicated data member(s).

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

The following table lists the attributes and values of the Class Key Member table for the first member, "ordergroup_id", of the OrderFormHeader class key. Unspecified optional attributes are not shown. In the R/O column, R = required, O = optional.

Attribute name Attribute value Type R/O Purpose
KeyDefName "myOrderFormHeaderKey " String R Name of the class key.
MemberName "ordergroup_id" String R Identifies the data member that is part of the class key.
OrdinalPosInKey 0 Integer R The position of the data member in the key composition, starting with 0 (zero). The key is guaranteed unique only when the data members are processed in a specific order.
Description "First member of myOrderFormHeaderKey." String O Describes the key member.

The following table lists the attributes and values of the Class Key Member table for the second member, "OrderForm_Id", of the OrderFormHeader class key. Unspecified optional attributes are not shown. In the R/O column, R = required, O = optional.

Attribute name Attribute value Type R/O Purpose
KeyDefName "myOrderFormHeaderKey " String R Name of the class key.
MemberName "OrderForm_Id" String R Identifies the data member that is part of the class key.
OrdinalPosInKey 1 Integer R The position of the data member in the key composition, starting with 0 (zero).
Description "Second member of myOrderFormHeaderKey." String O Describes the key member.

Running Example - Step 5

Create the members of the OrderFormHeader class key.

Ee796326.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 Key Member table for the first member.
   recNew.Open "KeyMember/myOrderFormHeaderKey/ordergroup_id", _
    cnnConnection, adModeWrite, adCreateOverwrite

'Set the attributes for the first key member.
   recnew("MemDefName") = "ordergroup_id"
   recNew("OrdinalPosInKey") = 0
   recNew("Description") = "First member of myOrderFormHeaderKey."
   recNew("KeyDefName") = myOrderFormHeaderKey

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

'Create an instance in the Key Member table for the second member.
   recNew.Open "KeyMember/myOrderFormHeaderKey/OrderForm_Id", _
    cnnConnection, adModeWrite, adCreateOverwrite

'Set the attributes for the second key member.
   recnew("MemDefName") = "OrderForm_Id"
   recNew("OrdinalPosInKey") = 1
   recNew("Description") = "Second member of myOrderFormHeaderKey."
   recNew("KeyDefName") = myOrderFormHeaderKey

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

The next step is to create a relation between the "new" OrderFormHeader class and the existing OrderGroup class.

See Also

Creating a new Class Relation

Create Schema Object Script

Copyright © 2005 Microsoft Corporation.
All rights reserved.