Discussion in 'microsoft.public.sqlserver.datamining' started by anonymous_user, May 23, 2007.

  1. I want to create a mining structure using a cube programmatically
    All the examples I found use as a source a datasourceview to build the mining structure.
    But we built a cube using a datasourceview and the next step is to build the mining structure using the cube.
    Can anyone help me ?
    anonymous_user, May 23, 2007
    1. Advertisements

  2. Here is an example that:
    - uses Analysis Management Objects (AMO, Microsoft.AnalysisServices.dll) to
    manipulate Analysis Services objects
    - creates a mining structure bound to a cube and not a relational data

    The code adds only 3 columns to the mining structure, and creates no model.
    The code for creating models inside a cube-based structure is the same as
    for a relational -based structure.

    using Microsoft.AnalysisServices;

    Server srv = new Server();

    Database db = srv.Databases["Adventure Works DW"];

    MiningStructure ms = db.MiningStructures.Add("CubeStruct");

    string dataSourceId = ".";
    string cubeId = "Adventure Works DW";
    string dimensionId = "Dim Customer";
    ms.Source = new CubeDimensionBinding(dataSourceId, cubeId, dimensionId);

    // Add a key column
    ScalarMiningStructureColumn keyColumn = ms.Columns.Add("Dim Customer", "Dim
    keyColumn.IsKey = true;
    keyColumn.Type = MiningStructureColumnTypes.Text;
    keyColumn.Content = MiningStructureColumnContents.Key;
    string keyAttributeId = "Dim Customer";
    keyColumn.Source = new CubeAttributeBinding(cubeId, dimensionId,
    keyAttributeId, AttributeBindingType.All);

    // Add two scalar columns
    ScalarMiningStructureColumn column = ms.Columns.Add("Commute Distance",
    "Commute Distance");
    column.Type = MiningStructureColumnTypes.Text;
    column.Content = MiningStructureColumnContents.Discrete;
    string attributeId = "Commute Distance";
    column.Source = new CubeAttributeBinding(cubeId, dimensionId, attributeId,

    column = ms.Columns.Add("House Owner Flag", "House Owner Flag");
    column.Type = MiningStructureColumnTypes.Text;
    column.Content = MiningStructureColumnContents.Discrete;
    attributeId = "House Owner Flag";
    column.Source = new CubeAttributeBinding(cubeId, dimensionId, attributeId,


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Please do not send email directly to this alias. It is for newsgroup
    purposes only.

    Bogdan Crivat [MSFT], May 23, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.