Jaa


RelatedColumn (clsColumn)

Note

  This feature will be removed in the next version of Microsoft SQL Server. Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible.

The RelatedColumn property of a clsColumn identifies a column to which the column is related.

Data Type

String

Access

Read/write for columns with a SubClassType of sbclsRegular whose IsKey property is False, read-only for all others.

Remarks

For columns with a SubClassType of sbclsRegular whose IsKey property is set to True and for columns with a SubClassType of sbclsNested, this property returns an empty string.

The functionality of the RelatedColumn property differs depending on the context of its usage:

  • The RelatedColumn property is used to relate a column in a nested table to a column in the case table (that is, the parent table) of the data mining model. In this case, the column's IsParentKey property is set to True.
  • The RelatedColumn property is used to define hierarchical relationships between columns. For example, you can use it to define that the Region column is related to the State column, the State column is related to the City column, and so on. For another example, consider a case set involving customer purchases. If ProductName is a column defined in the model, a column called ProductType can have its RelatedColumn property set to the ProductName column to indicate that its information is related to the ProductName column.
  • The SpecialFlag property is used with the RelatedColumn property. Consider the example in which a column is defined using the SpecialFlag property to contain a probability. In this case, the RelatedColumn property is used to determine which column the probability is based on. If a column is defined that is related to the CreditRisk column and contains a probability, the column would contain the numeric probability of a given credit for a given case.

Examples

A. Creating a Key Column and Relating it to a Key in the Case Table

The following example creates a key column in the case table for a mining model. It then creates a nested table based on three different tables and establishes the relationships between them (that is, their joins). Finally, it establishes a key column within this nested table and relates it to the key column in the case table.

'Define the key column for the case table.
Set dsoColumn = dsoDmm.Columns.AddNew("KeyColumn")
dsoColumn.SourceColumn = "Key"
dsoColumn.DataType = adInteger
dsoColumn.IsKey = True

'Define a nested table and relate the tables it is based on in a join.
Set dsoNestedCol = dsoDmm.Columns.AddNew("Products", sbclsNested)
dsoNestedCol.FromClause = "Sales, SalesReps, Products"
dsoNestedCol.JoinClause = "Sales.SalesRep = SalesReps.Name " & _
    "AND Sales.Product = Products.Product"
dsoNestedCol.Filter = ""

'Create a parent key column for the nested table and relate it to a column in the case table.
Set dsoColumn = dsoNestedCol.Columns.AddNew("CustomerID")
dsoColumn.SourceColumn = "CustId"
dsoColumn.DataType = adInteger
dsoColumn.IsParentKey = True
dsoColumn.RelatedColumn = "KeyColumn"

B. Establishing a Hierarchical Relationship Between Columns in a Nested Table

The following example builds a hierarchical relationship between the columns as they are added to a nested table. The following diagram shows their structure.

Set dsoColumn = dsoNestedCol.Columns.AddNew("Product Name")
dsoColumn.SourceColumn = "Sales.Product"
dsoColumn.DataType = adWChar
dsoColumn.IsKey = True

Set dsoColumn = dsoNestedCol.Columns.AddNew("Product Type")
dsoColumn.SourceColumn = "Products.Type"
dsoColumn.DataType = adWChar
dsoColumn.RelatedColumn = "Product Name"

Set dsoColumn = dsoNestedCol.Columns.AddNew("Product Category")
dsoColumn.SourceColumn = "Products.Category"
dsoColumn.DataType = adWChar
dsoColumn.RelatedColumn = "Product Type"

Set dsoColumn = dsoNestedCol.Columns.AddNew("Aisle")
dsoColumn.SourceColumn = "Products.Aisle"
dsoColumn.DataType = adWChar
dsoColumn.RelatedColumn = "Product Name"

C. Establishing a Probabilistic Relationship

The following example adds a column to a nested table. It then adds a second column whose contents will contain a probability based upon the first column.

Set dsoColumn = dsoNestedCol.Columns.AddNew("Quantity")
dsoColumn.SourceColumn = "Sales.Quantity"
dsoColumn.DataType = adDouble
dsoColumn.ContentType = "CONTINUOUS"

Set dsoColumn = dsoNestedCol.Columns.AddNew("pQuantity")
dsoColumn.SourceColumn = "Sales.pQuantity"
dsoColumn.DataType = adDouble
dsoColumn.RelatedColumn = "Quantity"
dsoColumn.SpecialFlag = "PROBABILITY"

See Also

Reference

clsColumn

Help and Information

Getting SQL Server 2005 Assistance