Professional Documents
Culture Documents
Case Study of Building A Data Warehouse With Analysis Services
Case Study of Building A Data Warehouse With Analysis Services
A1
1ET N!C!"NT !N
DECLARE
8s0l_strin9 N#ARC$AR(1)%:
, 8time_member_+e( INT
, 8'alendar_date_dt 1,ALLDATETI,E
, 8'alendar_da(_o-_.ee+_num INT
, 8'alendar_da(_o-_.ee+_name #ARC$AR(1)
, 8'alendar_da(_o-_mont/_num INT
, 8'alendar_da(_o-_(ear_num INT
, 8'alendar_.ee+_num INT
, 8'alendar_mont/_num INT
, 8'alendar_mont/_name #ARC$AR(1)
, 8'alendar_0uarter_num INT
, 8'alendar_(ear_num INT
1ET 8'alendar_date_dt ; 8start_date_dt
<$ILE (8'alendar_date_dt =; 8end_date_dt
BE>IN
I4 N!T E?I1T1
(
1ELECT time_member_+e(
4R!, dim_time
<$ERE 'alendar_date_dt ; 8'alendar_date_dt
BE>IN
1ELECT
8'alendar_da(_o-_.ee+_num ; DATE7ART(d., 8'alendar_date_dt
, 8'alendar_da(_o-_.ee+_name ; DATENA,E(<EE@DAY,
8'alendar_date_dt
, 8'alendar_da(_o-_mont/_num ; DATE7ART(DD, 8'alendar_date_dt
, 8'alendar_da(_o-_(ear_num ; DATE7ART(DY, 8'alendar_date_dt
, 8'alendar_.ee+_num ; DATE7ART(<@, 8'alendar_date_dt
, 8'alendar_mont/_num ; DATE7ART(,, 8'alendar_date_dt
, 8'alendar_mont/_name ; DATENA,E(,!NT$, 8'alendar_date_dt
, 8'alendar_0uarter_num ; DATE7ART(AA, 8'alendar_date_dt
, 8'alendar_(ear_num ; DATE7ART(YYYY, 8'alendar_date_dt
, 8time_member_+e( ;
CA1T(
CA1T(8'alendar_(ear_num A1 #ARC$AR 5
RI>$T(6))6 5 CA1T(8'alendar_da(_o-_(ear_num A1 #ARC$AR, B
A1 INT
1ELECT 8s0l_strin9 ;
6IN1ERT INT! 6 5 8dim_table_name 5
6 (6 5
6time_member_+e(, 6 5
6'alendar_date_dt, 6 5
6'alendar_da(_o-_.ee+_num,6 5
6'alendar_da(_o-_.ee+_name,6 5
6'alendar_da(_o-_mont/_num,6 5
6'alendar_da(_o-_(ear_num,6 5
6'alendar_.ee+_num,6 5
6'alendar_mont/_num,6 5
6'alendar_mont/_name,6 5
6'alendar_0uarter_num, 6 5
6'alendar_(ear_num6 5
6 6 5
6#AL"E1 6 5
6(6 5
C$AR(BC 5 CA1T(8time_member_+e( A1 #ARC$AR 5 C$AR(BC 5 6,6 5
C$AR(BC 5 CA1T(8'alendar_date_dt A1 #ARC$AR 5 C$AR(BC 5 6,6 5
CA1T(8'alendar_da(_o-_.ee+_num A1 #ARC$AR 5 6,6 5
C$AR(BC 5 8'alendar_da(_o-_.ee+_name 5 C$AR(BC 5 6,6 5
CA1T(8'alendar_da(_o-_mont/_num A1 #ARC$AR 5 6,6 5
CA1T(8'alendar_da(_o-_(ear_num A1 #ARC$AR 5 6,6 5
CA1T(8'alendar_.ee+_num A1 #ARC$AR 5 6,6 5
CA1T(8'alendar_mont/_num A1 #ARC$AR 5 6,6 5
C$AR(BC 5 8'alendar_mont/_name 5 C$AR(BC 5 6,6 5
CA1T(8'alendar_0uarter_num A1 #ARC$AR 5 6,6 5
CA1T(8'alendar_(ear_num A1 #ARC$AR 5 66
E?EC sp_eDe'utes0l 8s0l_strin9
END
1ET 8'alendar_date_dt ; 8'alendar_date_dt 5 1
END
EF no. use load_dim_time pro'edure to populate dim_time table .it/
needed dates FE
E?EC load_dim_time dim_time, 61E1ECG6, 61E1ECC6
-@7 -erver has a fine 4+7 toolEData +ransforation -ervi$es 0D+-1Ewhi$h yo" $an levera#e to e!e$"te
and s$hed"le D/ pop"lation ro"tines. , typi$al D+- pa$'a#e deterines whi$h data rows need to be
e!tra$ted fro their so"r$e and inserts s"$h rows into appropriate diension and fa$t tables. Be$a"se this is
a saple appli$ation, I won(t need to $reate any D+- pa$'a#es, b"t 'eep in ind that real-world 4+7
ro"tines $an #et &"ite $opli$ated and i#ht ta'e several wee's to develop.
Suary
In this first arti$le of the series, I introd"$ed yo" to the steps involved in b"ildin# a typi$al data wareho"se.
%o" learned how to $reate and pop"late a diensional data odel whi$h will be a $ornerstone of yo"r
wareho"se and analyti$al reports. +he ne!t arti$le fo$"ses on presentin# wareho"se data to the "sers.
In Part +wo of his series, database adinistration e!pert Baya Pavliashvili e!plores the $hallen#es
involved in b"ildin# and aintainin# a wareho"sin# sol"tion "sin# a siple database wareho"se.
+he first arti$le in this series introd"$ed yo" to steps involved in b"ildin# a data wareho"se. It also presented
an e!aple s$enario of solvin# b"siness probles with a data wareho"se. +his arti$le $ontin"es e!plorin#
$hallen#es involved in b"ildin# and aintainin# a wareho"sin# sol"tion.
Analysis Services Cu#es
-o far we have diension and fa$t tables in the wareho"se. ?ow we $an $reate diensions and $"bes
within )- ,nalysis -ervi$es. Plenty of t"torials and arti$les e!ist, showin# yo" step-by-step wi2ards that
,nalysis -ervi$es s"pplies for $reatin# diensions and $"bes, so I won(t repeat the here. Instead, Fi#"re
1 shows yo" the final view of the data within ,nalysis )ana#er.
Fi#"re 1 Hiew of the $"be data within ,nalysis )ana#er.
?C+4
+his saple appli$ation re&"ires no spe$ial treatent within ,nalysis -ervi$es. %o" $an easily follow
Diension /i2ard and :"be /i2ard steps to b"ild a reasonable $"be. B"t in the real-world yo" need to
define $al$"lated ebers, treat ebers on ea$h level within diension hierar$hy differently, and "$h
ore. I will show soe tips and tri$'s within ,nalysis -ervi$es in y "p$oin# arti$le.
If we had a data so"r$e that was $ontin"o"sly "pdated by ?orthwind eployees, we wo"ld also have to
repro$ess the $"be to a'e s"re it had "p-to-date data. %o" $an pro$ess $"bes an"ally thro"#h ,nalysis
)ana#er or "se ,nalysis -ervi$es Pro$essin# +as' within D+-.
Analytical $iews
Cn$e yo" have b"ilt $"bes, yo" are ready to $reate $"sto reports for displayin# the data to yo"r "sers. %o"
have several options for the D/ presentation layer. )i$rosoft 4!$el pivot tables are a fine way to analy2e
data if yo" B"st need basi$ f"n$tionality. In fa$t, be$a"se ost or#ani2ations "se 4!$el as a spreadsheet
ana#eent tool, yo" are li'ely to $reate any of yo"r reports in 4!$el. %et another option that $oes with
)- Cffi$e is "sin# Cffi$e /eb :oponents to $reate siple web pa#es for viewin# the wareho"se data.
-everal third-party vendors s"pply advan$ed analyti$s( tools for a $onsiderable pri$e. Perhaps the ost
$oonly 'nown b"siness intelli#en$e vendors in$l"de :o#nos, Pro:larity, )i$ro-trate#y, and B"siness
CbBe$ts. ,ltho"#h yo" $o"ld write a $"sto reportin# tool for yo"r own $opany(s needs, rest ass"red that
third-party vendors have e!$ellent offerin#s that yo" won(t at$h with a sall effort.
7et(s ta'e a brief loo' at a $o"ple of analyti$al views in Pro:larity to see the f"n$tionality available in this
tool. Fi#"re 2 shows the top five prod"$ts that ?orthwind sold in 1;;6.
Fi#"re 2 Pro:larity view of top five prod"$ts sold in 1;;6.
%o" $an easily $han#e the diensions and eas"res presented on the report, siply by dra##in# and
droppin# the diensions and eas"res yo" wish to see on rows and $ol"nsD yo" $an also $hoose fro a
variety of $hart types to eet the spe$ifi$ needs of yo"r "sers.
Pro:larity also allows yo" $reate a >de$oposition tree> to see the brea'down of yo"r b"siness operations.
For e!aple, the de$oposition tree in Fi#"re 3 shows the top five $"stoer $o"ntries where ?orthwind
sold prod"$ts in 1;;9. It f"rther infors "s we sold in 16 other $o"ntries in 1;;9, and these botto 16
$o"ntries a$$o"nt for appro!iately 36 per$ent of sales.
Fi#"re 3 Brea'down of 1;;9 sales by $"stoer on $o"ntry level.
?e!t we $an e!pand one of the top nodes, perhaps Ierany, to find o"t whi$h $ities a$$o"nted for ost
sales there 0see Fi#"re 51.
Fi#"re 5 Brea'down of sales in Ierany.
+he de$oposition shows that :"newalde was the top $ity for sales a$$o"ntin# for alost half of all sales in
Ierany. Cn the other hand, the botto si! $ities a$$o"nted for only 12 per$ent of all sales. If we drill down
"nder Bra2il(s =io de Janeiro, we see that all sales in this $ity $ae fro three stores 0see Fi#"re 61.
Fi#"re 6 -ales in =io de Janeiro.
,s yo" $an see, Pro:larity enables yo"r b"siness "sers to browse the data and $reate very int"itive and
inforative reports witho"t any pro#rain#. ,red with this tool and the $"bes yo" desi#n, e!e$"tives $an
a'e strate#i$ de$isions for iprovin# the b"siness.
"D% &ueries
Dis$"ssion of data wareho"sin# and b"siness intelli#en$e wo"ldn(t be $oplete witho"t a brief overview of
)D. &"eries. MDX is a lan#"a#e for &"eryin# ,nalysis -ervi$es $"bes. *nfort"nately, )D. is poorly
do$"ented and has $opli$ated #raar. Aowever, if yo" wish to b"ild yo"r own front-end D/ tools or
even $"stoi2e views prod"$ed by third-party tools, yo" "st learn )D.. /ritin# very siple )D. &"eries
is easyD in fa$t, s"$h &"eries reseble -@7 to a de#ree. +he )D. shown in Fi#"re 6 ret"rns 1;;9 sales by
$o"ntry.
1ELECT HCustomer.I'ustomer 'ountr(J .membersK on ro.s,
Hmeasures.Itotal saleJ K on 'olumns
4R!, sales
<$ERE (ItimeJ.I1CC*J
Fi#"re 6 +otal sales by $o"ntry in 1;;9.
Aowever, don(t e!pe$t to see "$h siilarity between -@7 and )D. on$e yo" #et past the basi$ &"eries.
For e!aple, let(s see what it wo"ld ta'e to report an avera#e of all sales on I'ustomer 'it(J level if
yo" also wanted to report the total sales within ea$h *.-. $ity. Ieneratin# s"$h a report in +ransa$t--@7 is a
20-se$ond tas' for any reasonable pro#raerD however, in )D. it is &"ite a $hallen#e. , &"ery wo"ld loo'
li'e what is shown in Fi#"re 8.
<IT$ 1ET bla/ A1 6HDE1CENDANT1('ustomer. usa , 1K6
1ET ro.set A1 6$IERARC$ILE(H bla/ , >ENERATE( bla/ ,
HANCE1T!R('ustomer.Current,ember, 1 KK6
,E,BER measures. aMera9e A1 6aM9(
INTER1ECT( bla/ , DE1CENDANT1('ustomer.Current,ember, 'ustomer.
'ustomer 'it( , measures. total sale 6
1ELECT Hmeasures. aMera9e K !N C!L",N1,
H ro.set K !N R!<1
4R!, sales
Fi#"re 8 ,vera#e sales in the *- and total sales in ea$h $ity.
I( not an opponent of )D.D on the $ontrary, I believe )D. is an e!treely powerf"l lan#"a#e, b"t d"e to
la$' of #ood do$"entation and a rather liited s"pply of )D. boo's it is diffi$"lt to aster. Indeed, there
are very few pro#raers who $an write advan$ed )D.. +he #ood news is that any front-end tools
0in$l"din# 4!$el and Pro:larity1 will write )D. for yo". +he not-so-#ood news is that )D. written by s"$h
tools isn(t always what yo" need on yo"r reports. In a n"tshell, if yo"r b"siness "sers wo"ld li'e the
f"n$tionality that isn(t s"pported by tools s"$h as :o#nos or Pro:larity, they sho"ld e!pe$t to spend top
dollar on an )D. reso"r$e 0and #ood l"$' findin# a #ood one1.
DW "aintenance
)"$h li'e any database syste, data wareho"se re&"ires $onsiderable aintenan$e that sho"ldn(t be
overloo'ed. ,s the wareho"se #rows, the database adinistrator "st deterine the optial physi$al layo"t
for data files, file #ro"ps, tables, and inde!es. +his is an e!aple of operational aintenan$e.
Data so"r$es pop"latin# the wareho"se tend to $han#eD therefore, yo" will li'ely have to $han#e the D+-
pa$'a#es as well. For e!aple, if ?orthwind a$&"ires another $opany 0perhaps -o"thwind1, yo"r "sers
will probably want to e!aine -o"thwind(s orders "sin# the e!istin# tools. -iilarly, if yo"r boss de$ides that
he wo"ld li'e a report showin# ?orthwind orders by shippers to see whi$h shipents #et to their destination
on tie, yo"(ll have to add new diensions and eas"res to yo"r wareho"se.
Suary
+his series of arti$les showed a very siple e!aple of b"ildin# a data wareho"sin# sol"tion. 4ven with this
saple, n"ero"s steps "st be ta'en to b"ild an a$$"rate, f"n$tionin# wareho"se. /hat(s ore iportant,
the wareho"se is never >finished>Eit $ontin"es to evolve and #row alon# with $opany(s reportin#
re&"ireents. +herefore, before "nderta'in# a D/ initiative, ens"re that yo" have appropriate s"pport fro
the b"siness owners. ,ltho"#h yo"r boss i#ht re&"est a data wareho"se overni#ht, he<she isn(t #oin# to rip
any benefits fro s"$h syste. Be s"re to entor and ed"$ate yo"r sta'eholders so that their
e!pe$tations are appropriate fro the #et-#o