官术网_书友最值得收藏!

Time for action – creating the first cube

There are two ways to create a cube: through Cube Wizard or by creating an empty cube. When we create a cube from the wizard, the relationships between measures and dimensions will be created automatically based on the underlying Data Source View (DSV) after choosing it. However, if we create a cube from an empty one, we need to set up a relationship between the measure groups and dimensions in the cube designer. In the next example, we create the cube using Cube Wizard.

  1. The first step is to create a data source connection. To create a data source connection, right-click on a data sources folder.
  2. Open the SSAS project and select New Data Source. As shown in the next screenshot, create a connection to the AdventureWorksDW2012 database. In the Impersonation Information field, enter the username and password of a domain/windows account that has the appropriate permissions for that database. Name the data source AdventureWorksDW2012.
    Time for action – creating the first cube
  3. There is one more step before creating the cube, and that step is the creation of the Data Source View. Right-click on the Data Source Views folder and choose New Data Source View. Choose the data source from step 1. In the Select Tables and View step, choose the tables as shown in the next screenshot and name the data source view AdventureWorksDW2012:
    Time for action – creating the first cube

    Tip

    You can also use the Add Related Tables button, as shown in the previous screenshot, to include all objects related to the selected object.

  4. After creating DSV, you will see a database style diagram of tables with their relationship in the design area. In this example, we just use the DSV as is, but in the next section, we will show you how to modify the DSV.
  5. Now, it is time to create the cube. Right-click on Cubes and select New Cube. Follow the steps in the wizard, and in the Select Creation Method step, choose Use Existing Tables.
  6. In the Select Measure Group Tables step, select the checkbox of the FactInternetSales table.
  7. In the Select Measures step, just leave all the measures as checked. Rename the measure group Internet Sales.
  8. In the Select New Dimensions step, leave all the tables as checked except for Fact Internet Sales. Rename all the options in Dimension in this step, and remove Dim from their name, as shown in the following screenshot:
    Time for action – creating the first cube
  9. Rename the cube Internet Sales.

What just happened?

In the first step of your example, you created a data source connection to a data warehouse. The credential used to create this connection is important because SSAS will use that credential to connect to the underlying database.

In the next step, a DSV is created from the data source. You can add as many tables and views as you want to the data source view; the data source view creates the base structure for cube development.

In steps 4, 5, and 6, you created a cube through Cube Wizard from the existing tables in the data source view. To create cubes, you should define your measure groups and dimensions. Measure groups are similar to the Fact tables, each measure group may contain one or more facts. In this example, the FactInternetSales table is selected as a measure group, and it contains measures such as Sales Amount and Order Quantity.

In step 7, we saw that dimensions are the second important items that should be defined when you create the cube. In the example, dimensions such as Date, Product, and Sales Territory are used. Each dimension may be connected to a dimension table in DSV or to a view that is a result of joining multiple tables of the database.

After creating the cube, you will see a view of the cube in the cube designer. The following screenshot shows the different parts of SSDT:

What just happened?

The Solution Explorer pane (number 1 in the screenshot) is part of SSDT that shows projects and files, data sources, DSVs, cubes, and other project-related items.

The Properties window (number 2 in the screenshot) is the place where you can view and change the properties of the selected object; for example, in the previous screenshot, the Properties window shows the properties of the Internet Sales cube.

The cube designer (number 3 in the screenshot) is the main designer in the SSDT in which you will spend most of your time as an SSAS developer. Here, you can view the layout of the cube's measure group and dimensions (number 7 in the screenshot); you can go to different tabs (number 8 in the screenshot), such as Dimension Usage, Partitions, Browser, and KPIs. We will walk through many of these tabs in this chapter.

A list of the Measure groups and their measures (number 4 in the screenshot) can be viewed in the Cube Structure tab. You can also see two different lists of dimensions: first is the database's dimensions (number 6 in the screenshot) and second is the cube's dimensions (number 5 in the screenshot). The difference between the cube's and the database's dimension is that there might be some dimensions in the database that are not used in this cube (for example, consider an SSAS project with multiple cubes). On the other hand, there might be a single database dimension that is used multiple times in one cube, which we will call the role-playing dimension (for example, there is only one database dimension, Date, but there are three role-playing dimensions in the cube, which are named Order Date, Ship Date, and Due Date).

One of the benefits of creating a cube from a wizard is that it will automatically create all the relationships between the database dimensions and the measure groups, based on the relationship defined in the DSV.

主站蜘蛛池模板: 灵台县| 寻甸| 二连浩特市| 泗水县| 贡山| 监利县| 澄江县| 墨脱县| 肥东县| 岫岩| 北票市| 通城县| 渭源县| 乌鲁木齐县| 眉山市| 深水埗区| 册亨县| 涞水县| 吉林市| 邵武市| 十堰市| 莱阳市| 辉县市| 青岛市| 赣州市| 昭觉县| 诏安县| 武安市| 阿拉尔市| 神农架林区| 舒城县| 福海县| 雷波县| 汤阴县| 突泉县| 洪江市| 兴城市| 钟祥市| 台北市| 仪征市| 榆树市|