Creating a New Class Data Member

This section describes how to create a new data member for a class in the Data Warehouse. The class must exist prior to creating the data member.

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

Ee796325.caution(en-US,CS.20).gifCaution

  • When adding a member to a class that is stored in a Data Warehouse with multiple Web sites, name each new member uniquely or ensure that the data type for the new members is the same. If a member exists in the same class in multiple Web sites and the members do not have the same data type, a failure might occur or data might be incorrectly converted when the Transaction Import DTS task is run.

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

The running example (which originates in Creating a New Class) continues by creating the OrderForm_Id and ordergroup_id data members of the OrderFormHeader class. For details about the existing class, see OrderFormHeader. Additional class members are created in the same way.

The following table lists the attributes and values in the Member Definition table for the OrderForm_Id data member. Unspecified optional attributes are not shown. In the R/O column, R = required, O = optional.

Attribute name Attribute value Type R/O Purpose
MemberDefName "OrderForm_Id" String R Uniquely identifies the data member for the class.
ClassDefName "OrderFormHeader" String R Stores the name of the containing class.
TypeName "UUID" String R Identifies the data type of the data member. For a complete list of types, see OLE DB Provider for Commerce Server.
Description "Identifier for an order form." String O Describes the data member.
IsActive 1 Integer O This is an active data member (that is, instances can be added).
IsPersistent 1 Integer O Persist instances of this data member in the underlying data store.
IsPrimaryKey 0 Integer O This attribute is set to True (1) when the GenerateKeyDef attribute is True in the class definition. This is to have the OLE DB Provider for Commerce Server automatically generate the class key. This is not allowed for multi-membered keys.
IsRequired 1 Integer O This data member is required.

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

Attribute name Attribute value Type R/O Purpose
MemberDefName "ordergroup_Id" String R Uniquely identifies the data member for the class.
ClassDefName "OrderFormHeader" String R Stores the name of the containing class.
TypeName "UUID" String R Identifies the data type of the data member.
Description "Unique identifier for the OrderGroup class." String O Describes the data member.
IsActive 1 Integer O This is an active data member (that is, instances can be added).
IsPersistent 1 Integer O Persist instances of this data member in the underlying data store.
IsPrimaryKey 0 Integer O This attribute is set to True (1) when the GenerateKeyDef attribute is True in the class definition. This is to have the OLE DB Provider for Commerce Server automatically generate the class key. This is not allowed for multi-membered keys.
IsRequired 1 Integer O This data member is required.

Running Example - Step 3

Create the new OrderForm_Id and ordergroup_id data members for the OrderFormHeader class.

Ee796325.note(en-US,CS.20).gifNotes

  • 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 Member Definition table for the first member.
   recNew.Open "Member/OrderFormHeader/OrderForm_Id", cnnConnection, _
    adModeWrite, adCreateOverwrite

'Set the attributes.
   recNew("ClassDefName") = "OrderFormHeader"
   recNew("TypeName") = "UUID"
   recNew("Description") = "Identifier for an order form."
   recNew("IsPrimaryKey") = 0
   recNew("DefaultValueAsStr") = "{00000000-0000-0000-0000-000000000000}"
   recNew("MemberDefName") = "ordergroup_id"
   recNew("GenerateColumnDef") = 1


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

'Create an instance in the Member Definition table for the second member.
   recNew.Open "Member/OrderFormHeader/ordergroup_id", cnnConnection, _
    adModeWrite, adCreateOverwrite

'Set the attributes.
   recNew("ClassDefName") = "OrderFormHeader"
   recNew("TypeName") = "UUID"
   recNew("Description") = "Identifier for an order form."
   recNew("IsPrimaryKey") = 0
   recNew("DefaultValueAsStr") = "{00000000-0000-0000-0000-000000000000}"
   recNew("MemberDefName") = "OrderForm_Id"
   recNew("GenerateColumnDef") = 1

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

The next step in the example is to create the key used to uniquely identify an instance of the OrderFormHeader class.

See Also

Creating a New Class Key

Create Schema Object Script

Copyright © 2005 Microsoft Corporation.
All rights reserved.