IsParentKey (clsColumn)
Observação |
---|
Esse recurso será removido na próxima versão do Microsoft SQL Server. Não utilize esse recurso em desenvolvimentos novos e modifique, assim que possível, os aplicativos que atualmente o utilizam. |
The IsParentKey property of an object of ClassType clsColumn indicates whether the column is a foreign key that relates to a column in the case table. This property, when used with the IsKey property, serves to uniquely identify the rows in a nested table.
Data Type
Boolean
Access
Read/write for columns with a SubClassType of sbclsRegular that belong to a clsMiningModel object with a SubClassType of sbclsRegular, read-only for all others.
Comentários
The IsParentKey property always returns False for columns with a SubClassType of sbclsNested and for columns belonging to a mining model with a SubClassType of sbclsOlap.
The IsParentKey property indicates which column in the nested table contains the foreign key to the case table, and it assists in creating the SQL JOIN clause used for the training query. For example, if a data mining model is constructed from the store table, with a key column named Store ID based on the store_id field, and a nested column based on the sales_fact_1998 table is added, a column related to the Store ID column (that is, a clsColumn object with a RelatedColumn property set to "Store ID") is created with the source column set to the store_id field in the sales_fact_1998 table and the IsParentKey set to True.
Examples
Creating a Data Mining Model With a Nested Column
The following code example creates a new relational data mining model named Test Model in the FoodMart 2000 database. Test Model is based on the store table in the FoodMart data source. The nested column Sales Fact 1998, based on the sales_fact_1998 table, contains a parent key column named Parent Store ID. The Parent Store ID column, defined from the store_id column in the sales_fact_1998 table, is related to the Store ID column in the data mining model defined from the store_id column in the store table.
Public Sub CreateDMMWithNestedColumn()
Dim dsoServer As DSO.Server
Dim dsoDB As DSO.Database
Dim dsoDMM As DSO.MiningModel
Dim dsoColumn As DSO.Column
Dim dsoNestedColumn As DSO.Column
' Initialize server.
Set dsoServer = New DSO.Server
' Connect to the local Analysis server.
' If a connection cannot be made, an error is raised.
dsoServer.Connect "LocalHost"
' Connect to the FoodMart 2000 database.
Set dsoDB = dsoServer.MDStores("FoodMart 2000")
' Create a new relational data mining model.
Set dsoDMM = dsoDB.MiningModels.AddNew("Test Model", sbclsRelational)
' Set the properties for the data mining model.
With dsoDMM
.FromClause = """store"""
.MiningAlgorithm = "Microsoft_Decision_Trees"
.DataSources.Add dsoDB.DataSources("FoodMart")
End With
' Create the key and predictable columns for the mining model.
Set dsoColumn = dsoDMM.Columns.AddNew("Store ID", sbclsRegular)
With dsoColumn
.SourceColumn = """store"".""store_id"""
.DataType = adInteger
.IsKey = True
End With
Set dsoColumn = dsoDMM.Columns.AddNew("Store Type", sbclsRegular)
With dsoColumn
.SourceColumn = """store"".""store_type"""
.DataType = adWChar
.IsKey = False
.IsInput = True
.IsPredictable = True
.ContentType = "DISCRETE"
End With
' Create the nested column.
Set dsoColumn = dsoDMM.Columns.AddNew("Sales Fact 1998", sbclsNested)
With dsoColumn
.FromClause = """sales_fact_1998"""
.IsInput = True
.IsPredictable = False
End With
' Create the parent key column for the nested column.
Set dsoNestedColumn = dsoColumn.Columns.AddNew("Store ID", sbclsRegular)
' Set the properties for the parent key column.
With dsoNestedColumn
.SourceColumn = """sales_fact_1998"".""store_id"""
.DataType = adInteger
.IsKey = False
.IsInput = False
.IsPredictable = False
.IsParentKey = True
.RelatedColumn = "Store ID"
End With
' Create the key and predictable columns for the nested column.
Set dsoNestedColumn = dsoColumn.Columns.AddNew("Product ID", sbclsRegular)
With dsoNestedColumn
.SourceColumn = """sales_fact_1998"".""product_id"""
.DataType = adInteger
.IsKey = True
.IsInput = True
.IsPredictable = False
.IsParentKey = False
End With
Set dsoNestedColumn = dsoColumn.Columns.AddNew("Store Sales", sbclsRegular)
With dsoNestedColumn
.SourceColumn = """sales_fact_1998"".""store_sales"""
.DataType = adInteger
.ContentType = "CONTINUOUS"
.IsKey = False
.IsInput = True
.IsPredictable = False
.IsParentKey = False
End With
' Save the new data mining model.
dsoDMM.Update
' Process the data mining model.
dsoDMM.Process
End Sub