Creating a New Class Key
For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.
This topic describes how to create a key as the unique identifier for a class. The class must exist before creating the key.
Note
For information about how to create classes, see Creating a New Class.
Keys can have a single member or multiple members. Keys must be unique across a catalog.
You can create a single-valued key in two ways:
Implicitly: Set the value of the GenerateKeyDef column to True (1) in the clsdef table, and set the value of the IsPrimaryKey to True (1) in the memdef table. Explicitly creating a new instance in the Class Key Definition table is then unnecessary.
Explicitly: First, create a new row in the clskeydef table, populate the columns, and save the changes. For information about the Class Key Definition, see Keydef Table: Key Definition Metadata.
Second, define the member of the key by creating a new row in the keymem table. For information about this step, see Creating a New Key Member.
For multi-member keys, you can only define the member of the key in the keymem table.
This example (which originated in Creating a New Class) continues by creating the (multi-member) key for the OrderFormHeader class.
The following table lists the columns and values of the clskeydef table for the OrderFormHeader class. Unspecified optional columns are not shown. In the R/O column, R = required, O = optional.
Column name |
Column value |
Type |
R/O |
Purpose |
---|---|---|---|---|
ClassKeyDefName |
"myOrderFormHeaderKey" |
String |
R |
Uniquely identifies the class key. Must be unique across the catalog. |
ClassDefName |
"OrderFormHeader" |
String |
R |
The name of the class for the key. |
Description |
"Unique key for the OrderFormHeader Class." |
String |
O |
Describes the key. |
Example - Step 4
Create a new key for the OrderFormHeader class.
Note
The code provided in this example is for demonstration only.
'Create an instance in the Class Key Definition table.
recNew.Open "Key/myOrderFormHeaderKey", cnnConnection, _
adModeWrite, adCreateOverwrite
'Set the attributes.
recNew("ClassDefName") = "OrderFormHeader"
recNew("Description") = "Unique key for the OrderFormHeader class."
'Save the new row.
recNew("__Commit") = 1
recNew.Fields.Update
recNew.Close
The next step is to define the members of this key. Continue to Creating a New Key Member.