Mining Object Model

The Mining Object Model (MOM) provides a structured way to interact with and manage data mining objects within SQL Server Analysis Services. This object model allows developers and administrators to programmatically create, modify, and query mining structures, models, and related objects.

Understanding the Core Components

The MOM is built around several key object types:

Key Operations Supported by MOM

The Mining Object Model facilitates a wide range of operations:

Using MOM with AMO

The Mining Object Model is part of the Analysis Management Objects (AMO) library. AMO provides a .NET Framework-compliant object model that exposes the administrative and object model features of Analysis Services. You can leverage AMO in your applications to:

Example: Creating a Basic Mining Structure

Here's a conceptual example of how you might use AMO to create a mining structure:


// Using Microsoft.AnalysisServices.dll
using Microsoft.AnalysisServices.Tabular; // Note: This example is conceptual and might lean towards Tabular, but MOM concepts apply to Multidimensional too.

// Assuming 'server' is an initialized Microsoft.AnalysisServices.Server object
// and 'database' is an initialized Database object.

// Define the mining structure
MiningStructure ms = new MiningStructure();
ms.ID = "MyCustomerMiningStructure";
ms.Name = "Customer Data Mining Structure";

// Define a source table
Table sourceTable = new Table();
sourceTable.ID = "DimCustomer";
sourceTable.Name = "Customer Dimension";
sourceTable.SourceType = SourceType.DataSourceView;
sourceTable.Source = "MyDataSourceView"; // Assuming a DataSourceView named 'MyDataSourceView'

// Define columns
Column customerKeyColumn = new Column();
customerKeyColumn.ID = "CustomerKey";
customerKeyColumn.Name = "Customer Key";
customerKeyColumn.DataType = DataType.Int64;
customerKeyColumn.KeyColumn = true; // Marks this as a key column
sourceTable.Columns.Add(customerKeyColumn);

Column ageColumn = new Column();
ageColumn.ID = "Age";
ageColumn.Name = "Age";
ageColumn.DataType = DataType.Int64;
ageColumn.SourceColumn = "Age"; // Maps to the source column name
ageColumn.ModelingFlags.Add(new ModelingFlag { Flag = ModelingFlagName.IsInput }); // Mark as input
sourceTable.Columns.Add(ageColumn);

// Add the table to the mining structure
ms.SourceTables.Add(sourceTable);

// Add the mining structure to the database
database.MiningStructures.Add(ms);

// Update the database to commit changes
database.Update();
            

Further Resources

Important: Ensure you have the correct AMO libraries referenced in your project and that your Analysis Services instance is accessible.