Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in...
Transcript of Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in...
![Page 1: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/1.jpg)
Building a Cube in Analysis
Services Step by Step and
Best Practices
Rhode Island Business Intelligence Group
November 15, 2012
Sunil Kadimdiwan InfoTrove
Business Intelligence
![Page 2: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/2.jpg)
Agenda
Data Warehousing
Introduction
Star/Snowflake Schemas
SQL Server Analysis Services
◦ Overview
◦ Components
Questions?
![Page 3: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/3.jpg)
Sunil Kadimdiwan: InfoTrove Inc.
Working with SQL Server since 1993
Focusing on Business Intelligence solutions ◦ PowerPivot & Power View, Analysis Services, Reporting
Services, Integration Services and SQL Server
Frequent speaker: User Groups & Code Camps
sunilk AT infotrove DOT com or 508-532-1180
Find me in LinkedIn: Sunil Kadimdiwan
![Page 4: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/4.jpg)
What does a cube mean?
Excel Demo
CrossTab report
◦ a sophisticated one perhaps!
![Page 5: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/5.jpg)
A simple example Order Date Product City Qty Unit Price Total Sales
10/22/09 Lock Washer
4
Seattle 200 $3.00 $600.00
01/14/10 Touring Rim Boston 5 $4000 $20000
Order Date = Date, Month/Week, Quarter,Year
Product = Product, Subcategory, Category
City = City, County, State, Region, Country, Territory
Metrics/Measures = Qty, Unit Price, Sales Total
![Page 6: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/6.jpg)
Another example A line item on a bill received from a doctor
What are the dimensions to derive? ◦ Date (of treatment)
◦ Doctor (maybe called "provider")
◦ Patient
◦ Procedure
◦ Primary Diagnosis
◦ Location (doctor's office/hospital)
◦ Billing Organization (an organization the doctor belongs to)
◦ Responsible Party (patient or patient's legal guardian)
◦ Primary Payer (often an insurance plan)
◦ Secondary Payer (party's spouse's insurance plan)
◦ Etc.
![Page 7: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/7.jpg)
Business Intelligence Architecture
* PeopleSoft, Oracle, SAP, CRM
Monitoring &
Administration
Metadata
Repository
![Page 8: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/8.jpg)
Star Schema
A Star Schema contains a fact table and one or more dimension tables.
1. A Fact Table: Stores numeric fact (measures) such as Sales dollars, Costs, Unit Sales etc.
2. Dimension Tables: They surround the Fact table, and they store descriptive information about the measures
The shape looks like a Star
![Page 9: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/9.jpg)
Star Schema
![Page 10: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/10.jpg)
Snowflake Schema
![Page 11: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/11.jpg)
Analysis Services 2008 R2
4th version of Analysis Services
◦ SQL Server 7.0, 2000, 2005 and 2008
Business Intelligence Development Studio
SQL Server Management Studio
![Page 12: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/12.jpg)
What is running?
Hardware
◦ HP Pavilion dv6; Dual core, 8GB RAM
◦Windows 7 Ultimate
Software
◦ SQL Server 2008 R2
◦ Analysis Services 2008 R2
![Page 13: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/13.jpg)
Database environment
Adventure Works DW 2008 R2
Contoso Retail DW
![Page 14: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/14.jpg)
Analysis Services Database
An Analysis Services database includes
◦Data Source
◦Data Source View
◦Dimension
◦Cube
◦ Security Role
![Page 15: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/15.jpg)
Data Source Connection
Defines how Analysis Services connects to a physical data
store using a managed Microsoft .NET Framework or native
OLE DB provider.
The connection string contains server name, database,
security, timeout, and other connection-related information.
Analysis Services directly supports many data sources.
◦ Supported: Microsoft SQL Server databases and databases created by
other products, including Oracle, DB2, and Teradata.
![Page 16: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/16.jpg)
Connection to SQL Server
Following providers will work:
◦ OLE DB provider for SQL Server
◦ SQL Native Client 10.0
◦ .NET Provider/SqlClient Data Provider
(Avoid using .NET data sources – OLEDB is faster for
processing in practices)
![Page 17: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/17.jpg)
Data Source Views New feature Since AS 2005 and onwards
A data source view is a logical representation of the data that
is used by Analysis Services objects, built from the data
sources already defined in the database.
Can contain multiple Data Sources
A data source view can contain relationships, calculated
columns, and queries that are not present in the underlying
data sources.
![Page 18: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/18.jpg)
Dimension
All dimensions are based on tables or views in a data source view.
All dimensions are shared since AS 2005 The structure of a dimension is largely driven by
the structure of the underlying dimension table or tables.
The simplest structure is called a star schema, which is where each dimension is based on a single dimension table that is directly linked to the fact table by a primary key - foreign key relationship.
![Page 19: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/19.jpg)
Dimension Consists of A dimension consists of:
◦ Attributes that describe the entity
◦ User-Defined Hierarchies that organize dimension members in meaningful ways such as
Date -> Month -> Quarter -> Year
![Page 20: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/20.jpg)
Attributes
New feature since AS 2005
Containers of dimension members
Typically have one-many relationships between
attributes in the same dimension:
◦ All attributes implicitly related to the key
![Page 21: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/21.jpg)
Measure Group
In a cube, a measure is the set of values, usually numeric, that are based on a column in the fact table in the cube.
A measure group contains one or more or all the measures from a single fact table. It can’t contain measures from different fact table.
![Page 22: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/22.jpg)
Measure Group Advantages
Measure groups provide the following
advantages:
◦ They can be partitioned and processed separately
◦ They allows to include measures from diff fact tables.
◦ They are grouped by granularity: Same measure group
same granularity.
◦ Security can be applied to specific measure groups
![Page 23: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/23.jpg)
Inside a Cube Measures and Measure Groups Dimensions Relationships Calculations Actions Partitions Perspectives
![Page 24: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/24.jpg)
Types of Dimensions
Different Dimension Relationships ◦ Regular Dimension Relationship
◦ Reference Dimension Relationship
◦ Fact Dimension Relationship
◦ Role Playing Dimension
◦ Parent-Child Hierarchy
![Page 25: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/25.jpg)
Regular Dimension Relationships
A traditional star schema design
The Primary Key in the dimension table joins directly to Foreign Key in the fact table.
![Page 26: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/26.jpg)
Reference Dimension Relationships
Snowflake schema A Reference dimension using columns from multiple
tables, or the dimension table links a dimension that is directly linked to the fact table.
![Page 27: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/27.jpg)
Role Playing Dimension It is used in a cube more than one time, each time for a
different purpose.
Each role-playing dimension is joined to a fact table on a different foreign key.
Example, you might add a Time dimension to a cube three times to track the times that
◦ products are ordered,
◦ products are shipped,
◦ Orders are due..
![Page 28: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/28.jpg)
Parent-Child Hierarchy A parent-child hierarchy is a hierarchy in a standard dimension
that contains a parent attribute. A parent attribute describes a self-join, within the same dimension table.
Example: Employee Hierarchy
An employee is an employee who reports to his/her manager. His manager is an employee as well
Employee Key self joins to ParentEmployeeKey
![Page 29: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/29.jpg)
Slowly Changing Dimension
Some attribute values may change over time.
Two basic techniques:
◦ Type 1 change
◦ Type 2 change
![Page 30: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/30.jpg)
Slowly Changing Dimension
– Type 1 A Type 1 change, is to simply overwrite the old value with the new one.
key salespersonid salesperson territory
101 405 tom jones Northeast
102 410 paul tomlinson Southwest
key salespersonid salesperson territory
101 405 tom jones Southeast
102 410 paul tomlinson Southwest
![Page 31: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/31.jpg)
Slowly Changing Dimension – Type
2 Create a new dimension row with the new value and a new surrogate
key
Mark the old row or timestamp as no longer in effect. The fact table will use the new surrogate key to link new fact measurements
key salespersonid salesperson territory startdate enddate
101 405 tom jones Northeast 4/24/2007
102 410 paul tomlinson Southwest 3/21/2005
key salespersonid salesperson territory startdate enddate
101 405 tom jones Northeast 4/24/2007 11/30/2009
102 410 paul tomlinson Southwest 3/21/2005
103 405 tom jones Southeast 12/1/2009
![Page 32: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/32.jpg)
Named Set A named set is a MDX expression that returns a set of
dimension members.
You can define named sets and save them as part of the cube definition.
It allows you to reuse the same named set throughout the cube.
Typical example:
◦ Create a list Top 10 Customers based on Sales, Worst Performing Products etc.
◦ You can reuse in different queries.
![Page 33: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/33.jpg)
Default Members
Every Dimension has a Default Member ◦ Usually the “All” member is the default member.
Default Measures ◦ The measures dimension also has a default measure
◦ In our sample cube [Adventure Works], the default member for the cube is [Reseller Sales Amount]
![Page 34: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/34.jpg)
Security
Setup Roles
![Page 35: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/35.jpg)
Advanced Topics KPI
Actions
Partitions
Aggregations
Perspectives
Translations
Browser
![Page 36: Building a Cube in Analysis Services Step by Step and Best ... · PDF fileBuilding a Cube in Analysis Services Step by Step and Best Practices Rhode Island Business Intelligence Group](https://reader031.fdocuments.net/reader031/viewer/2022030407/5a849a057f8b9a87368c1cb2/html5/thumbnails/36.jpg)
Questions?