设为首页收藏本站

 找回密码
 注册

QQ登录

只需一步,快速开始

BCM 门户 IT世界 应用开发 查看内容

Creating Dimensions in SSAS

2011-11-2 08:35| 发布者: Test| 查看: 1130| 评论: 0|来自: SQL Server Magazine

摘要: If you take the time to build proper dimensions, add useful hierarchies that support user’s navigational needs, then perform the important step of adding attribute relationships, you’ll realize seve ...

Now our project has two dimensions. We haven’t yet created a cube, but you can still process one or both of the dimensions, which involves reading the data from the dimension tables and building the dimension structure. After processing, verify the dimension structure by browsing the data in the dimension using the Browser tab at the top. In my example, I see a warning symbol next to the dimension name—this isn’t caused by the overly long name but indicates a fundamental problem with dimensions, which we’ll examine in Part 2.


Good Dimensions, Good Data Warehouses

When building a data warehouse, some developers new to SSAS downplay the need for proper dimensional modeling in the relational database, figuring that the tools in SSAS can overcome any deficiencies in the underlying relational schema. Although SSAS can create dimensions from a normalized schema, a relational data warehouse significantly simplifies the creation of dimensions and cubes in SSAS and also ensures cleaner data. For more information about dimensions and data warehousing, see this article’s online Learning Path at InstantDoc ID 98510. Now you’re ready to move on to Part 2 on the Web (InstantDoc ID 98699), where we’ll look at the reason for the warning symbol, create a cube, and discuss how attribute relationships help users process data.


Use attribute relationships to help the cube engine quickly respond to queries

SQL Server Magazine
InstantDoc ID #98699

Executive Summary:
In the quest to improve analysis time for users needing data, we look at creating dimensions, attribute relationships, and how they help the cube engine respond faster to queries. We look at a fundamental problem with dimensions by creating a cube, then discuss how to create attribute relationships, which help to speed the data analysis process.

To better help your users with data analysis, you create proper dimensions, which we covered in Part 1 of this article at InstantDoc ID 98510. We also discussed how to process the dimensions, and we found that our two-dimensional project was showing a warning symbol next to the Time dimension name. This wasn’t caused by the overly long name, but it does indicate a fundamental problem with dimensions, which we’ll examine shortly by creating a cube. Then we’ll look at how to create attribute relationships, which tell the cube how dimension attributes relate to each other and help to speed the data analysis process.


Creating the Cube

To understand why the Time dimension is showing a warning on its one hierarchy, let’s first build a cube. Right-click the Cubes folder in the Solution Explorer and select New Cube to open the Cube Wizard. The first screen confirms that the cube will be built from a data source, while the next screen shows the list of data source views. Next, the wizard attempts to determine which tables are dimension tables and which are fact tables. Normally the wizard determines this correctly based on the joins in the underlying relational database, but sometimes you’ll have to perform minor tweaks to correctly specify the table types. In addition, the page asks for the name of the time dimension table, if one exists; I selected DimTime as the time dimension table.

The next screen shows up only if dimensions already exist — it asks developers to select any existing dimensions they want in the cube. If additional dimensions are required, the cube wizard will create them, but for this example I’ll select the two dimensions just created. The next screen shows a list of all the possible measures from the fact table. The wizard selects any field with a numeric data type, so you must remove the foreign key fields in most cases. For this example I will select only the Sales Amount field.

After completing the wizard, the cube actually shows four dimensions: Product, Ship Date, Order Date, and Due Date. This is because there are three joins from the fact table back to the time dimension table. This is called a role-playing dimension and is discussed in the article "Data Warehousing: Dimensional Role-Playing," December 2007, InstantDoc ID 97272.

Now the cube can be processed. All the data from the fact table is read and loaded into the cube, ready for analysis.


Examining the Problem

This simple cube contains only Product and Time dimensions along with a single measure from the FactInternetSales table: Sales Amount. Figure 1 shows a view of the Sales Amount measure and the Calendar Quarter attribute from the Order Date dimension. Note that the Calendar Quarter attribute isn’t being pulled from the Calendar hierarchy but is simply the standalone attribute. Normally, attributes added to a hierarchy are then hidden as standalone attributes so as not to confuse users.

http://www.sqlmag.com/content/content/98699/Figure_01.gif

The query returns proper results, but notice that there are only four quarters shown. Each quarter is the total for that quarter for all years; normally, users want to see quarters broken down by year. By placing the Calendar Year attribute on the grid before the Calendar Quarter, the dimension will work as expected. However, there are two problems: First, users must know which attributes to drag over and in which order. Second, aggregations and indexes aren’t being built to facilitate the normal analysis that will be done, which is drilling down the Year to Quarter to Month to Day path.

Recall that the hierarchy, now called Calendar, had a warning indicator next to it. This warning indicates that this is not a natural hierarchy, and the term “natural hierarchies” will be explained in a moment. Therefore, queries at any level of the hierarchy other than the lowest level are suboptimal.


鲜花

握手

雷人

路过

鸡蛋

相关阅读

最新评论

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )  

GMT-8, 2025-12-13 12:10 , Processed in 0.012085 second(s), 16 queries .

Supported by Best Deal Online X3.5

© 2001-2025 Discuz! Team.

返回顶部