Partilhar via


Creating a New Data Member

This topic describes how to create a new data member for a class in the Data Warehouse. The class must exist before creating the data member. For information about how to create classes, see Creating a New Class.

Note

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

You create a data member by creating a new row in the memdef table, populating the columns, and saving the changes. For information about the memdef table, see Memdef Table: Member Definition Metadata.

The example (which originates in Creating a New Class) continues by creating the OrderForm_Id and ordergroup_id data members of the OrderFormHeader class. You create additional data members in the same manner.

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

Column name

Column 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 What is the 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, you can add instances).

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 2009 automatically generate the class key. This is not allowed for multi-member keys.

IsRequired

1

Integer

O

This data member is required.

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

Column name

Column 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, you can add instances).

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 2009 automatically generate the class key. This is not allowed for multi-member keys.

IsRequired

1

Integer

O

This data member is required.

Example - Step 3

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

Note

The code in this example is for demonstration only.

'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 that you use to uniquely identify an instance of the OrderFormHeader class.

See Also

Other Resources

Creating a New Class Key

Extending the Data Warehouse Logical Schema