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 inserting a new instance in the Key Member (KeyMem) table, populating the attributes, and saving the changes. For information on 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 | "OrderFormHeaderKey " | String | R | Name of the class key. |
MemDefName | "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 OrderFormHeaderKey." | 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.
Attribute Name | Attribute Value | Type | R/O | Purpose |
KeyDefName | "OrderFormHeaderKey " | String | R | Name of the class key. |
MemDefName | "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 OrderFormHeaderKey." | String | O | Describes the key member. |
Running Example - Step 5
Create the members of the OrderFormHeader class key.
'Create an instance in the Key Member table for the first member.
recNew.Open "KeyMem/OrderFormHeaderKey/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 OrderFormHeaderKey."
'Save the new row.
recNew("__Commit") = 1
recNew.Update
'Create an instance in the Key Member table for the second member.
recNew.Open "KeyMem/OrderFormHeaderKey/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 OrderFormHeaderKey."
'Save the new row.
recNew("__Commit") = 1
recNew.Fields.Update
The next step is to create a relation between the 'new' OrderFormHeader class and the existing OrderGroup class.