The Microsoft Data Warehouse Toolkit读书笔记(三):第二章 业务过程维度模型设计

第一章 业务过程维度模型设计

一、       Dimensional Modeling Concepts and Terminology

The dimensional model is the best way to meet our primary design goals:

·         To present the needed information to users as simply as possible

·         To return query results to the users as quickly as possible

·         To provide relevant information that accurately tracks the underlying business processes

1.      事实表

事实表的主键是由多个维度表的外键组成的复合主键。

A.     只有事实
i. 事实表大多由数值型字段组成。
ii. 并不是所有的数据都是事实,仅指与事件有关的数据。没有数据的事件,通常增加度量EventCount=1
iii. 导出数据:从其实事实数据中计算而来,可以在ETL过程中计算并写入事实表;或者在视图中计算;或者在SSAS模型中定义。

无加性事实:一致的,如单价;

半加性事实:随着查询上下文而变化,如月末余额。适合在SSAS中处理。

B.     粒度

强烈建议在事实表中定义尽可能详细的事实数据。并且所有的事实应在同一粒度级别上。

 

2.      维度

维度是维度模型的基础,用于描述业务对象。

维度属性是描述业务对象的数据,一般不经常变化。

维度具有一个或多个层次关系,或一对多关系。

维度表是不符合三范式设计原则的,存有冗余数据,有得于用户理解,并有且于查询性能。

3.      把事实和维度放在一起

 

4.      The Bus Matrix,共享维度,下挖

Adventure Works

Business Priority

<-- Conformed Dimensions -->

Data Warehouse Bus Matrix

Business Process

Date (Order, Start, Ship)

Product

Promotion

End Customer

Employee

Reseller

Page

Internet Registered User

Part

Vendor

Shipper

Problem

Account

Department

Currency (Source, Dest.)

Benefits Plan

Advertising

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TV

 

x

x

x

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Print

 

x

x

x

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Online

 

x

x

x

x

 

 

 

 

 

 

 

 

 

 

 

 

Promotions

 

x

x

x

x

 

x

 

 

 

 

 

 

 

 

 

 

Co-op programs

 

x

x

x

 

x

x

 

 

 

 

 

 

 

 

 

 

Web Site Marketing

 

x

x

x

x

 

 

x

x

 

 

 

 

 

 

 

 

PR

 

x

x

x

 

 

 

 

 

 

 

 

 

 

 

 

 

Orders Forecasting

2

x

x

x

 

x

x

 

 

 

 

 

 

 

 

 

 

Reseller Orders

1

x

x

x

 

x

x

 

 

 

 

 

 

 

 

 

 

Internet Orders

1

x

x

x

x

 

 

x

x

 

 

 

 

 

 

 

 

Purchasing

 

x

x

 

x

x

 

 

 

x

x

x

 

 

 

 

 

Parts Inventory

 

x

x

x

 

 

 

 

 

x

x

 

 

 

 

 

 

Manufacturing

6

x

x

 

 

 

 

 

 

x

 

 

 

 

 

 

 

Finished Goods Inv.

 

x

x

x

 

 

 

 

 

 

 

 

 

 

 

 

 

Shipping

 

x

x

x

x

x

x

 

 

 

 

x

 

 

 

 

 

Returns

5

x

x

 

x

x

x

 

 

 

 

x

 

 

 

 

 

Registration cards

 

x

x

 

x

 

 

 

 

 

 

 

 

 

 

 

 

Customer Calls

4

x

x

x

x

x

x

 

 

x

 

 

x

 

 

 

 

Web Support

 

x

x

 

x

x

x

x

x

 

 

 

x

 

 

 

 

Financial Forecasting

 

x

x

x

x

x

x

 

 

 

x

 

 

x

x

 

 

Exchange Rate Mgmt.

3

x

 

 

 

 

 

 

 

 

 

 

 

 

 

x

 

GL-Revenue & Expense

 

x

 

 

 

 

 

 

 

 

 

 

 

x

x

 

 

Cost Accounting

 

x

x

 

 

 

 

 

 

 

 

 

 

x

x

 

 

Payroll

 

x

 

 

 

x

 

 

 

 

 

 

 

 

x

 

 

Benefits Enrollment

 

x

 

 

 

x

 

 

 

 

 

 

 

 

 

 

x

 

 

二、       其它设计概念和技术

1.      代理键

代理键的优点如下:

n         保护DW系统不随源系统的改变改变

n         有得于集成多个源系统的数据

n         可以向DW中增加源系统中不存在的数据,如对缺失值指向维度表的一行

n         允许跟踪维度表中随时间变化的属性

n         数值型的代理键在关系数据库与AS中效率都很高

 

2.      缓慢变化维

如果维度的属性可以改变值,需要跟踪这种变化,就要建立缓慢变化维(SCD)。

有三种类型:

n         Type 1: 覆盖原值,不保留历史

n         Type 2: 保留全部历史

n         Type 3: 保留上次历史

 

应用案例:如需要按地区统计历史销售量,如果地区重新划分过,只有保留历史才能保留正确分析。

3.      日期维

日期维应使用有意义的日期字段作为代理键。这称为角色扮演维。

4.      Degenerate Dimensions

如果相关属性的维,如transaction ID

 

5.      雪花模型

部分使用雪花模式是合理的,尤其当维度模型十分复杂时,但务必让全业务用户不要直接接触到如此复杂的模型。

6.      多值维

现实世界中存在两种复杂关系:

n         事实表与维度表间的多对多关系

n         维度表之间的多对多关系

A.     事实表与维度表间的多对多关系

如一个销售单可能有多个销售员参与,这时就要建立bridge table

但这样引入一个风险,多次重复计算,如统计销售量时

B.     维度间多对多

Note 

Analysis Services 2005 has new functionality to support many-to-many dimensions. Analysis Services expects exactly the same kind of structure that we described in this section. They call the bridge table an intermediate fact table, which is exactly what it is

C.     层次
i. Variable-Depth Hierarchies(可变深度层次)

即父子维度实现——parent-child data structure

ii. frequently changing hierarchies(经常变化层次)

如要保留父子维度的历史,将维度表转化为事实表

D.     Heterogeneous Products(继承关系)
E.     Aggregate Dimensions(怎样存储不同粒度的数据)


Each subcategory includes a mix of color, size, and weight attributes, for example. Therefore, most of the columns in the Product table do not make sense at the Subcategory level. This results in a much shorter dimension, hence the common term shrunken dimension.

7.      Junk Dimensions (垃圾维)

经常在初始设计完成后发现,还有一些属性不属于任何维,但通常很重要,其实是代码表

四各处理方式:

1.  不处理,放在事实表中

2.  为每个属性建立一个维,以保证不会遗忘它们

3.  单独建立一个维存放这些属性

4. 

 

8.      三种事实表类型

There are three fundamental types of fact tables in the DW/BI system: transaction, periodic snapshot, and accumulating snapshot

 

Note 

Transaction fact tables are clearly what Analysis Services was designed for. Your Analysis Services database can accommodate periodic and accumulating snapshots, but you do need to be careful. The problem is not the model, but the process for updating the data. Snapshot fact tables—particularly accumulating snapshots—tend to be updated a lot in the ETL process. This is expensive but not intolerable in the relational database. It’s far more expensive for Analysis Services, which doesn’t really support fact table updates at all.

For snapshot facts to work in Analysis Services for even moderate-sized data sets, you’ll need the Enterprise Edition feature that allows dimensional database partitioning.

 

三、       维度建模过程


Figure 2.9: The dimensional modeling process flow diagram

1.      准备

A.     Identifying Roles and Participants

Table 2.5: Major Participants in Creating the Dimensional Model

PARTICIPANT

PURPOSE/ROLE IN MODELING PROCESS

Data modeler

Primary responsibility

Business analyst

Analysis and source expert, business definitions

Data steward

Drive agreement on enterprise names, definitions and rules

Business power user

Describe and refine data sources and business rules from a user perspective

Source system developer

Source expert, business rules

DBA

Design guidance, Early learning

ETL designer

Early learning

ETL developer

Early learning

Steering Committee

Naming, business definitions, model validation

 

B.     Understanding the Data Architecture Strategy

确定技术架构:STAGE DB->relational db -> OLAP

C.     建立建模环境

模型的初始设计在EXCEL文件中进行,这么易于进行修改。模型变得稳定以后,则可以将模型转换成标准建模工具建模。

D.     建立命名规范

参考资料:http://www.lifecycle-toolkit.com/tools/nmngcnv/modelstd/namest.htm

2.      Data Profiling and Research

通过查看数据,对数据质量状况进行评估,并发现数据间的关系:

n         The domain and distribution of the data in each column in a table

n         Relationships between columns, such as hierarchies and derivations

n         Relationships between tables, such as hidden foreign key relationships or columns with similar content

n         Common patterns in the data, such as telephone numbers, or zip codes, or money

n         Data quality problems, such as outlier values or exceptions to a common pattern, or exceptions to a relationship

一般通过工具进行数据查看工作。

通过与源系统开发人员、报表开发人员和业务用户会谈,进一步了解。

3.      建立高层维度模型

四个步骤:

1)  选择业务过程,即建模的主题域。

2)  选择粒度

3)  选择维度

4)  选择事实表

 

四、       案例学习—— Adventure Works 采购维度模型

1.      选择维度

日期、产品(BOM),销售区域、员工、客户和零售商、促销、货币

role-playing dimension means the same table will be used multiple times, either through views, synonyms, or physical copies of the table.

2.      为维度与事实定义属性

3.      详细模型设计

A.     定义缓慢变化维
B.     定义事实表

与事实表有关的问题的有:

n         导出字段

n         计算分摊

n         共享维度

n         衰退维度

4.      最终维度模型

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值