Freigeben über


Creating a New Class Relation Member

This topic describes how to map a data member of a parent class to a data member of a child class. This enables the data member in the parent class to be seen and populated by the child class. When a relation is created between classes, the key members from the parent class are automatically mapped to the child class (as non-key members) but not persisted in the child class. In this example, the key of the child class and all members of the key must be persisted. Therefore this behavior must be overridden. By creating the relation member explicitly, you can set the persistence of the data member.

Note the following information:

  • The relation between the classes must already be defined.

  • The classes must contain the respective data members before you create the relation member.

  • You create a relation member by creating a new row in the relmem table, populating the columns, and saving the changes. For information about the relmem table, see Relmemdef Table: Relation Member Definition Metadata.

  • The example (which originated in Creating a New Class) concludes by creating a new relation member that maps the ordergroup_id data members of the OrderFormHeader and OrderGroup classes.

For information about class relations and data members, see Creating a New Class Relation and Creating a New Data Member, respectively.

The following table lists the columns and values in the relmem table for the ordergroup_id member relation. Optional columns are not shown. In the R/O column, R = required, O = optional.

Column name

Column value

Type

R/O

Purpose

RelationName

"OrderGroupToOrderFormHeader "

String

R

Identifies the class relation.

ParentMemName

"ordergroup_id"

String

R

Identifies the name of the parent class member.

ChildMemName

"ordergroup_id"

String

R

Identifies the name of the child class member.

Description

"OrderGroup.ordergroup_id to OrderFormHeader.ordergroup_id relation member."

String

O

Describes the logical concept underlying the relation.

Example - Step 7

Create a relation member that maps the ordergroup_id data members of the OrderFormHeader and OrderGroup classes and save the updated schema.

Note

The code in this example is for demonstration only.

'Create an instance in the Relation Member Definition table.
   recNew.Open _
   "RelMember/OrderGroupToOrderFormHeader/ordergroup_id/ordergroup_id", _
    cnnConnection, adModeWrite, adCreateOverwrite

'Set the attributes.
   recNew("ParentMemName") = "ordergroup_id"
   recNew("ChildMemName") = "ordergroup_id"
   recNew("Description") = "OrderGroup.ordergroup_id to " & _
    "OrderFormHeader.ordergroup_id relation member."

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

'Commit the changes to the Data Warehouse schema.
   cmdCommand.CommandText = "CommitSchema"
   cmdCommand.Execute

'Turn off "Schema Change" mode.
'If SchemaMode is set to a value other than On, True, or 1
' it is turned off. 
   cmdCommand.CommandText = "SchemaMode=0"
   cmdCommand.Execute

'Close the connection.
   cnnConnection.Close

'Release the objects.
   Set recNew = Nothing
   Set cmdCommand = Nothing
   Set cnnConnection = Nothing

This finishes the example of extending the Data Warehouse to include the OrderFormHeader class.

If the OrderFormHeader class was not a preexisting Data Warehouse class, you would have to create custom log import tasks to populate the new class with user data. Additionally, you would have to create custom calculations to access the new structures for reporting.

See Also

Other Resources

Extending the Data Warehouse Logical Schema

Creating a New Class

OrderFormHeader

Relmemdef Table: Relation Member Definition Metadata