(Lecture 3) Star Schema.pdf

MobeenMasoudi 99 views 20 slides Jul 31, 2022
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

Star Schema


Slide Content

Star Schema
Asimpledatabasedesigninwhichdimensionaldataareseparated
fromfactoreventdata.Adimensionalmodelisanothernamefora
starschema.
1

Fact tables and Dimension tables
Facttablescontainfactualorquantitativedata(measurementsthatare
numerical,continuouslyvalued,andadditive)aboutabusiness,suchas
unitssold,ordersbooked,andsoon.
Dimensiontablesholddescriptivedata(context)aboutthesubjectsof
thebusiness.Thedimensiontablesareusuallythesourceofattributes
usedtoqualify,categorize,orsummarizefactsinqueries,reports,or
graphs;thus,dimensiondataareusuallytextualanddiscrete(evenif
numeric).
2

NOTE:Adatamartmightcontainseveralstarschemaswithsimilar
dimensiontablesbuteachwithadifferentfacttable.Typicalbusiness
dimensions(subjects)areProduct,Customer,andPeriod.Period,or
time,isalwaysoneofthedimensions.
3

Components of a Star Schema
4

An example for Star Schema
1. Which cities have the highest sales of large products?
2. What are the average monthly sales for each store manager?
3. In which stores are we losing money on which products? Does this
vary by quarter?
5

6

Surrogate Key
Everykeyusedtojointhefacttablewithadimensiontableshouldbea
surrogate(nonintelligent,orsystem-assigned)key,notakeythatusesa
businessvalue(sometimescalledanatural,smart,orproductionkey).
7

GRAIN OF THE FACT TABLE
Thelevelofdetailinafacttable,determinedbytheintersectionofall
thecomponentsoftheprimarykey,includingallforeignkeysandany
otherprimarykeyelementsiscalledgrain.
Anexampleofacommongrainwouldbeeachbusinesstransaction,
suchasanindividuallineitemoranindividualscanneditemona
productsalesreceipt,apersonnelchangeorder,alineitemona
materialreceipt,aclaimagainstaninsurancepolicy,aboardingpass,or
anindividualATMtransaction.
8

Estimating the size of the fact table
1.Estimatethenumberofpossiblevaluesforeachdimension
associatedwiththefacttable(inotherwords,thenumberofpossible
valuesforeachforeignkeyinthefacttable).
2.Multiplythevaluesobtainedinthefirststepaftermakingany
necessaryadjustments.
9

Anexample
10

An example (cont…)
With the grain of the table changed to daily item totals, the number of
rows is computed as follows:
11

MODELING DATE AND TIME
Becausedatawarehousesanddatamartsrecordfactsabout
dimensionsovertime,date,andtime,hence‘Date’isalwaysa
dimensiontable,andadatesurrogatekeyisalwaysoneofthe
componentsoftheprimarykeyofanyfacttable.
Becauseausermaywanttoaggregatefactsonmanydifferentaspects
ofdateordifferentkindsofdates,adatedimensionmayhavemany
nonkeyattributes.Also,becausesomecharacteristicsofdatesare
countryorevent-specific(e.g.,whetherthedateisaholidayorthereis
somestandardeventonagivenday,suchasafestivalorfootball
game),modelingthedatedimensioncanbemorecomplex.
12

Modeling dates Illustration
13

Variations of the Star Schema
Multiple fact tables with conformed dimensions
Conformed Dimensions: One or more dimension tables associated with
two or more fact tables for which the dimension tables have the same
business meaning and primary key with each fact table.
In general, conformed dimensions allow users to do the following:
• Share nonkeydimension data
• Query across fact tables with consistency
• Work on facts and business subjects for which all users have the same
meaning
14

15

FACTLESS FACT TABLES
There are applications for fact tables that do not have nonkey(fact)
data but do have foreign keys for the associated dimensions.
16

Factlessfact table showing occurrence of an
event
17

Factlessfact table showing coverage
18

Using Helper tables for multivalued
dimensions
19

Snowflakeschema
An expanded version of a star schema in which dimension tables are
normalized into several related tables.
When the dimension tables are further normalized by using helper
tables (sometimes called bridge tables, or reference tables), the simple
star schema turns into a snowflake schema.
20
Tags