这是最好的时代,这是最坏的时代,这是智慧的时代,这是愚蠢的时代;这是信仰的时期,这是怀疑的时期;这是光明的季节,这是黑暗的季节;这是希望之春,这是失望之冬;人们面前有着各样事物,人们面前一无所有;人们正在直登天堂;人们正在直下地狱。 我也要与时俱进了,被itpub2.0牵着尾巴,拼命的奔跑,不停的灌水...

关于数据仓库的设计!

上一篇 / 下一篇  2008-02-13 17:16:09 / 个人分类:数据仓库专区

下面以SQLServer2000和Analysis Service为例,并结合以前的项目经验,把相关的知识和大家一起分享探讨!在公司时用英文写的,懒得做翻译了!
;Q4~i(NFk&a4iQ9BE0

Data Warehouse Concept

A data warehouse is a subject-oriented, integrated, nonvolatile, time-variant collection of data designed to support management DSS needs.

1、Subject-Oriented

Subject-Oriented data is organized around major subject areas of an enterprise and is useful for an enterprise-wide understanding of those subjects. For Example, a banking operational system maintains independent records of customer savings, loans, and other transactions. A warehouse pulls this independent data together to provide financial information.
j9N0]$SWH iiR0E0The data from diverse sources is transformed so that it is consistent and meaningful for the warehouse.ITPUB个人空间iLkhv
So the main work is around the fact table.
x}j&n%C6W01.1 Original data from data source
oA?\Wt3J.d01.2 Dimension

P]f7[Ctf4bx1]5K01.3
MeasurementITPUB个人空间b0s*gt+Yl"`#`^.[K
1.4
dimension granularity
gGdLG;L#H01.5
Star model or snowflake modelITPUB个人空间1r C,du*h?z
1.6
OLAP model

2、Integrated

Data on a given subject is integrated.ITPUB个人空间x6P&T)p1L*k
In many organizations, data resides in diverse independent systems, making it difficult to integrate the information into a single set of meaningful data from analysis. A key characteristic of a warehouse is that data is completely consolidated or integrated. Data is structured in a globally accepted manner, even when the underlying source data is structured differently (conforming dimension). Integration and transformation processes can be time-consuming and costly. It requires commitment from every part of the organization, particularly top-level managers who make the decisions and allocate resources and funds.
5IU9R ?X,Q+F6@0So the main work may be like :ITPUB个人空间b*Xh0Ta~)g$[
2.1 Universal dimension from different department.

Bs1q&zn }BK+K|02.2
Dimension design include NULL value or violate constraintITPUB个人空间,K,Q9?[lT
2.3
Define mid-exchange table2.4But we didn’t control the data quality caused by man-made

3、Nonvolatile

Typically, data in the data warehouse is read-only (less volatile than operational systems). Data is loaded into the data warehouse for the first-time load, and then refreshed regularly. Warehouse data is accessed by business users. Warehouse operations typically involve:ITPUB个人空间 D*A,iJ'k7sL,`swL.M
Loading the initial set of warehouse data (often called the first-time load)ITPUB个人空间YN3qds
Refreshing the data regularly (called the refresh cycle)ITPUB个人空间A2x0jZ9r
So the main work is around:
UQC4lk0o:qe X03.1 DTS design and schedule
ITPUB个人空间7V@({(R7Pa6t!Pt
3.2
The dimension data is incremental, it is to say that they can be inserted and updated, but can’t be deleted. And dimension data must be unique.ITPUB个人空间2wn sD%c?
3.3 The original or fact data is incremental, but according to requirement, it can be updated or deleted under the control. The full process is danger and impossible when the data volume is too huge.

4、Time-Variant

Warehouse data is by nature historical; data is retained for a long time, from two to ten years, compared with one to three months of data for a typical operational system. The data allows for analysis of past and present trends, and for forecasting, using what-if scenarios.
ch_cgH1@|0Base the Time-Variant and data volume, we must consider :
rH+r3|8_ ?!P2H04.1 The design about the database
4.2The design about the tableITPUB个人空间:Xn|x8|s?
4.3
The OLAP increment

数据库设计,主要针对SQLServer2000而言,包括以下方面:
i'D { }Op9n&ka e0
Qz m {Z4Z0数据库设计
4Y1Of*D8[|;F0文件组设计
2I!^)U%r7?.cns!E0历史数据表和当前数据表设计ITPUB个人空间P x6x4['F$]q!dJ
分区表设计ITPUB个人空间f4^#rP^ EL:|
数据库链接使用
M*[w@o l@#k0日志表
*b$nx3W] M,M G0增量数据抽取ITPUB个人空间O2X"Uk4p9z8I
维度数据抽取ITPUB个人空间L1?a1{3[lW6v\ PUS
原始数据抽取ITPUB个人空间(p6y/iqY]g DT
日结数据处理
5js5L-~v!t#|y0OLAP的增量处理和分区
;vGA2gN tWO/]V0数据库调优

数据库设计

数据库一般的分类方式有:ITPUB个人空间Voz%K%x1op6k
按照业务来分(财务系统和销售系统)
.}*s,O Qh"rU{0按照处理阶段来分(原始数据和日结数据)ITPUB个人空间@0^+LK(v
按照数据存储时间来分(当前数据和历史数据)

当然这些分类标准不是一成不变的也可以交叉分类,而且不同的关系数据库也不一致,如Oracle可以使用不同数据块大小的表空间存储不同数据,SQLServer和Sybase则采用不同的数据库实现对数据的存储。
3RwtEM5X2ma0建议数据库的分类按照不同的处理阶段进行数据存储,可以方便的进行数据库的备份管理工作。如
-U3A)Maj|'[V0dataware_org 存储ODS层数据,保留一定期限的原始数据ITPUB个人空间#oCi@7P!U v6p
dataware_fact 存储日结数据,可以较长时间的保留系统数据。
!q-n mj}+j0dataware_dim 存储维度基础数据。

待续........

关于文件组的设计
/xGidO C0
e3v iD#f EdV0
数据库可以按照以下几种情况进行文件组设计(其实同上,关键如何分类更加合理)ITPUB个人空间2Eu I:k{g
1
、按照业务数据来源分类ITPUB个人空间$Aa,_ f SF#Q"R"}\
2
、按照ETL处理过程分类ITPUB个人空间 K.e^I9`#Tk^?h-oN
3
、按照数据的存储周期分类(历史数据还是临时数据)ITPUB个人空间 }d+^b9N
4
、按照数据的物理存储类型分类(即索引还是数据)
vCLzE+N"c0ITPUB个人空间\%Va9|{ i(e{D/C
个人建议,采用按照物理存储类型和数据存储周期进行分库,如ITPUB个人空间 P \Pf z_|3J J
历史数据文件组ITPUB个人空间0^,{:| } Ih@ i:g
临时表数据文件组ITPUB个人空间Y[0ucI
索引文件组

关于历史数据和临时数据的分开处理
+u%X+L7kFs5_ebrQum"@0
%T{ x%QI U2T kM0
众所周知,对于大数据量的数据存储任何数据库都与遭遇性能瓶颈。
)EQf&JJ]4Mm0
因此建议对于大数据量的表采取分表处理:即将数据区分为临时数据和历史数据分开存储
1Rg9f6R ?0
w3f2G(a A4f5{^'q:p0
尽管可能会带来一些维护和处理上的不便,但是显而易见可以提升系统的性能。临时表中少量的数据可以有效地进行日结等处理,临时表数据需要进行定期地进行数据的转移工作。
+u&lN'n*cH I0
还有一个更大的好处是,临时表和历史表放在不同的文件组或者数据库中,可以减少系统的IO冲突和备份周期的制定.

关于分月表的问题
T.\4k:T9Nci%j0
Rc&[-OFTQ0
首先SQLServer在数据处理中存在性能问题,当一张表数据超过1000万以上时,其查询更新删除的效率显著降低,因此每个数据表的数据量要控制在一定范围内;其次SQLServer不支持分区处理。但是SQLServer2000提供了一种类似分区的解决办法,采用分月表形式(当然也可以按照其他分)ITPUB个人空间Sm'b]/d'V+Pp

G:A \ \&b*]E0
即采用UNION的形式将各个相同表结构的表合并起来,作为一个完整的表来使用。当然这种视图仍存在一定的性能问题和限制(以后会逐步发散开来)
V![7_&}2G&^a0
例如:ITPUB个人空间 A;j)}8P8q3X:`
create view v_fact_table as
:S-F*yi)YH0select * from t_fact_table_200601 union allITPUB个人空间 qA LQX?!l
select * from t_fact_table_200602 union all
#ux"N/Fylv5_0select * from t_fact_table_200603
/d0ZpwG7C:Q5e-p0
每个月自动产生一张t_fact_table_YYYYMM数据表,然后动态更新v_fact_table视图。

数据库链接
\!]-e*auh T0
链接服务器配置允许Microsoft® SQL Server™对其它服务器上的OLE DB数据源执行命令。链接服务器具有以下优点:
%sI9rUril*d0
远程服务器访问。
!]XZ!Bsjf0
对整个企业内的异类数据源执行分布式查询、更新、命令和事务的能力。ITPUB个人空间,o2ZG7pOo b K0j
能够以相似的方式确定不同的数据源。ITPUB个人空间#@"e%JKj5b]
链接服务器有以下两种形式:
3m4b6ud,n(a&GX6? G0SELECT * FROM LinkedDatabase..usename.table
KRt5j&yt)v+t}2E4L0SELECT * FROM OPENQUERY(LinkedDatabase, 'SELECT * FROM table')
} ^u:dkRhrEM]0
两种各有优缺点
p9C,MJt G0
第一种写法更加清晰,但有时候受限制比较多ITPUB个人空间 ?C U$h,p1}c\
第二种写法更加通用一些,甚至可以执行远程存储过程

关于控制表和日志表ITPUB个人空间y%Z-@+rf"y/}A
1
、监控维度数据的抽取和完成状态ITPUB个人空间6g,D&j+F K+[
2
、监控原始业务数据的抽取和完成状态(包括时间点增量幅度的控制)
[1ju{5Ot:G%aGS03
、监控事实数据的运行和处理状态(包括时间点增量幅度的控制)
"`$zq|sf0D`X}04
、监控OLAP增量处理的状态和时间点
rx;Dv_:T0zh0ETL
部分——关于维度抽取
JB)GZf"a+~rI0
(PvofH0~01
、普通维度的抽取和处理ITPUB个人空间.R/}`^!sA~;wO~Ds
2
、父子维度的抽取和处理ITPUB个人空间$N+? Ih,?"X2r
3
、雪花维度的抽取和处理ITPUB个人空间5q i5M N&@ra"]

:?S+h/`1G*y0
关于维度的处理方式,主要包括三种方法ITPUB个人空间4G4J[3h'b@q7f-R#I2c,\Q
1
、完全覆盖法,即只保留最后一次更新的记录ITPUB个人空间:U \4h;`v&\N Db
2
、全历史记录法,即采用替代键的方式对每次发生变更的记录进行记录,同时对此次业务数据的相应维度进行替换。
B)|)`;Foz;O0S03
、记录最新纪录及上一次历史,即只保留当前和上次的更新记录,前两种的这种策略。
7r @0xt-B&kJ9rZ5Q0ITPUB个人空间+cGFf*ll+A
通常情况下,对于维度不敏感的情况下采用第一种方式比较简单易行
nX,yc J8PC.aR0
第二种方法则相对比较复杂,对于系统处理的要求也比较高

ETL部分——关于原始业务数据抽取ITPUB个人空间v%|9_B6Kd"b

8c"Hyw!F.K0
主要是采取增量抽取的方式,此外还要考虑抽取对原业务系统的性能影响
3Z5xO+\4o0
?J\ pQLAJf)j0
通常的处理原则ITPUB个人空间9{%A4i:c |
减少每次数据抽取的时间和事务的大小,减轻数据抽取时对业务系统的性能影响。

ETL部分——关于数据日结的处理ITPUB个人空间-y(D(U#vfy[6p

|p/Ph E*o*V0
主要是采取增量处理的方式,此外还要考虑处理时对系统性能的影响ITPUB个人空间k!cj v ~7_-KJ ?i
ITPUB个人空间fnB4QNK1@]
通常的处理原则
(K!d RQ\;fZz0First get begin time from fact table or original tableITPUB个人空间6NY0]3r/O6V3HE&{g
Then get end time from original table, it need to be under the control by loglimitITPUB个人空间&j2_ M8_;I+@z1C8C;D
Loop between the begin time and end timeITPUB个人空间dz9F.}'m QIN
Modify the log table status

OLAP的设计和处理
s(C WG KH!G ^4k`0
$FRyMnT}&y-Y:~0
通常情况下对于大数据量的CUBE采用分区形式ITPUB个人空间,I$Sz y&u!Bc
对于CUBE处理而言,通常情况采用脚本形式,以方便数据的增量处理和CUBE分区的融合ITPUB个人空间J)JF%Nbl
ITPUB个人空间6[6GuN*s L A`
分区和增量的主要原因ITPUB个人空间~O#{lCk
全量数据刷新对系统性能影响很大
.^Ry(k{vb0
可以对分区进行局部处理,而不影响整个CUBE

关于数据仓库性能的优化主要包括:ITPUB个人空间jT })b {N D;l0Q.@A*o

3h!n)NE/}8gT01
、定期进行数据的转移和清除工作
.|)tNa'ODn \02
、定期实现对数据库日志的收缩,尤其是大事务的处理之后ITPUB个人空间(w%Uk%S+g
3
、定期进行数据库索引的重建工作。ITPUB个人空间'IseN_ZT'`$n

0ox(@&b/OB0
监控:
X{ gm0v6I1q6O0
定期通过Performance性能监视器收集数据库服务器的CPU,内存,硬盘统计信息
RJ6{} aiK0
定期分析DTS的日志信息
5X&S0d:HW R0
定期分析Windows的日志信息

关于备份ITPUB个人空间&CKbN,Mm3Ij bs

9IjL5hS2B0OLAP
的备份
DsmLqqa n2{1O0OLAP
是采用独占式处理方式的,备份时不允许CUBE的处理,因此要合理的进行OLAP的备份和数据处理的关系。ITPUB个人空间6?(z4Z'I4^#x,P

Y6fZ1\"@X0
脚本:
F)vr^yc3g0@echo offITPUB个人空间Z5Q8V.Z R!y0~t
rem save database,
lN"i5{~9\0rem switch to the path of backup commandITPUB个人空间T}+u'N[9W mb n7DMW
e:
nTz'mY4W.@;sV0cd e:Microsoft Analysis ServicesBin
'W8cXsC:}n0msmdarch /a
机器名"c:MSSQLCUBE" "BIOLAP" "F:BIBACKUPCUBEBIOLAP.CAB"
4H x)W l%o4M4U0
备份工作由Windows操作系统进行调度或者SQLServer均可ITPUB个人空间5G8P;Xv$Kl0@-c

@Q+B2YyT0
关于数据库的备份ITPUB个人空间8A;I8hxs!KQ F
数据库的备份也会影响系统的正常运行,因此也需要进行合理的调度工作任务
[ eO}JNCS;v0
备份的策略建议是ITPUB个人空间 Lx1GC/G7Tf
1
23456采用增量备份
D^0T.rz)@07
采用全量备份

没心事好好整理,其实可以扩展的东西很多......

也希望大家提出宝贵意见!


TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-09-07  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 22243
  • 日志数: 65
  • 建立时间: 2007-12-07
  • 更新时间: 2008-08-31

RSS订阅

Open Toolbar