S1 Teknik Informatika
DIMENSIONS NY
Sales of DVDs in NY
• A cell in the cube may store values (measurements) relative to the combination of the labeled dimensions
p ro d u c t month
category region year
product country quarter
state month week
city day
store
PRODUCT LOCATION TIME
NY DVD A g t DVDs in NY in August
Product Total Sales 1 2 3 4 1 $454 - - $925 Store 800 1 $454 - - $925 2 $468 $800 - - 3 $296 - $240 - S to re 4 $652 - $540 $745
Dimensional modeling adalah teknik untuk menstrukturkan data menurut konsep bisnis.
Dimensional model meliputi :
measures, ex: sales-in-items, sales-in-pound, dll. dimensions, ex: time, space, products
dimensions, ex: time, space, products
Dimension dapat distrukturkan (menyediakan view-view yang kurang/lebih detil) untuk summarize/analyze data
Dapat dibandingkan dengan :
ER model : “entities” and “relationships” UML schema : “classes”
4
Measure(s) – Data numerik
Misalnya jumlah produk permen yang dijual di toko X pada
tanggal 2 Maret 2006
Dimension(s) – parameter bisnis yang menentukan
transaksi. transaksi.
Misalnya : product, time, location
Tiap dimension menggambarkan sebuah “business entity” Dimension melibatkan atribut-atribut yang menjelaskan data
numerik/measure
Tiap dimension harus mempunyai single base level, yaitu level dengan granularity terbaik
dengan granularity terbaik
“day” dapat menjadi base level untuk “time” dimension
“products” dapat menjadi base level untuk “product” dimension “store” dapat menjadi base level untuk “location dimension”
6
Elemen base level tadi nanti dapat di aggregate/summarized ke level yang lain.
“days” weeks, months, quarter, year, ....
“products” brand, food/non-food, supplier, .... “store” city, region, country, urban/rural, ....
Elemen dimension adalah sesuatu yang masuk akal, tidak bergantung pada dimension lain
8
10
Dimension mempunyai attribute
Time dimension: day, month, year
Product dimension: ProductID, LineID, BrandID
Dimension distrukturkan/diorganisasikan dalam hierarchy
Time dimension: days weeks quarters Time dimension: days weeks quarters
Product dimension: product product line brand
Disebut juga Multidimensional data
Untuk memvisualiasasikan data dengan 1-3 dimensi. Untuk dimensi lebih tinggi, digunakan hypercube.
12
14
Roll-up : melihat view yang lebih summarized Drill-down : melihat view yang lebih detil
Slice and dice : melihat subview / subcube / bagian
tertentu saja dari data
Pivoting : merotasikan row/column/dimension untuk
melihat keadaan tertentu
16
Agregasi data ke level yang lebih tinggi
Climbing up hierarchy Dimension reduction
Contoh : roll-up sales (berdasar store,day, product) ke
average-sales (berdasar region, month, brand) average-sales (berdasar region, month, brand)
Untuk tiap dimension : up ke level mana ?
Untuk tiap measure : fungsi agregasi mana yang akan
Melihat data ke level yang lebih rendah / lebih tersebar
(reverse roll-up)
Contoh : drill down sales (berdasar region, month, brand)
ke sales (berdasar store, month, product)
Untuk tiap dimension : down ke level mana ? Untuk tiap dimension : down ke level mana ?
Untuk measure : drill down seringkali dapat dipakai
sebagai ‘undo’ agregasi
18
20
22
Hanya melihat bagian tertentu dari data saja (proyeksi
dan seleksi)
Contoh :
slice sales (berdasar region, month, brand) ke sales
(berdasar month, brand) untuk region NW saja. (berdasar month, brand) untuk region NW saja.
Untuk dimension :
24
Pivot :
merotasikan data, dapat dikombinasikan dengan slicing
Ranking :
melakukan top-N analysis
Kombinasi : Kombinasi :
mengkombinasikan beberapa cube sehingga dapat
26
Q1 Q2 Q3 Q4 1000 Canada USA 2000 ti me ( qu ar te rs ) locat ion (c ount r home entertainment computer item (types) phone security Toronto 395 Q1 Q2 605 Vancouver ti me (q ua rt er s) locat ion (cit i home entertainment computer item (types) 605 825 14 400 Q1 Q2 Q3 Q4 Chicago New York Toronto Vancouver ti me ( qu ar te rs ) locat ion (cit ies) 440 395 1560 dice for
(location = “Toronto” or “Vancouver”) and (time = “Q1” or “Q2”) and
(item = “home entertainment” or “computer”)
roll-up on location (from cities to countries)
Fig. 3.10 Typical OLAP Operations Chicago New York ion (cit ies) Q4 home entertainment computer item (types) phone security slice for time = “Q1” Chicago New York Toronto Vancouver computer security lo ca ti on ( ci ti es ) 605 825 14 400 drill-down on time (from quarters to months)
Modeling data warehouses:
Star schema: A fact table in the middle connected to a set of
dimension tables
Snowflake schema: A refinement of star schema where some
dimensional hierarchy is normalized into a set of smaller dimensional hierarchy is normalized into a set of smaller dimension tables, forming a shape similar to snowflake
Fact constellations: Multiple fact tables share dimension tables,
viewed as a collection of stars, therefore called galaxy schema or fact constellation
28
30
32
Mudah dipahami
Hirarki mudah dilihat : 1 dimension dalam 1 table, hirarki ada secara implisit di tabel
Performance kurang baik Dimension bisa menjadi
sangat banyak tabel
Mengurangi jumlah physical join (dibanding snowflake) Low maintenance
34
Tidak perlu lagi penanda level.
1 table per dimension / per agregated fact / per
kombinasi level
Performance bisa lebih lambat
Front end harus bisa mendeteksi adanya
agregated fact sehingga
DM-MA/S1IF/FTI/UKM/2010 36
kombinasi level agregated fact sehingga
meta data harus lebih banyak
Untuk menjawab single query mungkin butuh multiple SQL statement
Star, alternatifnya fact constellation.
Jika high cardinality (atribut & tuple banyak), sub select
dimension bisa relatif lambat.
Alternatif lainnya : snowflake
1 table per dimension level
38
Untuk tiap level dari dimension, dibuat 1 tabel.
Tiap tabel berisi atributnya ditambah ‘parent key’-nya Misal : dimension time (day,month,week,quarter,year)
dipecah menjadi time1(day,week,month), time1(day,week,month), time2a(week,year), time2b(month,quarter), time3(quarter,year) 40 DM-MA/S1IF/FTI/UKM/2010
Pahami dimension dan level-level di dalamnya Select mulai dari fact table
Pembuatan snowflake : mulai dari star, baru
DW collects information about subjects that span the
entire organization, such as customers, products, sales, assets, and personnel. Its scope is enterprise-wide.
For DW, fact constellation schema is commonly used since it can model multiple, interrelated subjects.
since it can model multiple, interrelated subjects.
Data Mart is a subset of a DW, focuses on a particular
subject. Its scope is department-wide. Typically, a data mart consisting of a single subject area (e.g. marketing,
operations).
For Data Mart, star or snowflake schema are commonly
used since both are geared towards modeling single subject
42
A data mart can be either dependent or independent.
A dependent data mart is a subset that is created directly
from the DW.
Consistent data model Providing quality data Providing quality data
DW must be constructed first
Jan Feb Mar Apr Mei Jun
Produk-1 100 40 90 40 20 50
Data Penjualan di Toko Cabang-1
Produk-1 100 40 90 40 20 50 Produk-2 70 50 30 100 30 80 Produk-3 80 30 60 50 100 60 Produk-4 50 70 70 60 50 70 Produk-5 60 80 50 40 80 30 DM-MA/S1IF/FTI/UKM/2010 44
Jan Feb Mar Apr Mei Jun
Produk-1 50 70 80 140 100 30
Data Penjualan di Toko Cabang-2
Produk-1 50 70 80 140 100 30
Produk-2 70 50 50 50 30 80
Untuk setiap query berikut ini :
tentukan operator OLAP apa yang harus dilakukan terhadap data di atas, sehingga
dapat memberikan informasi yang diperlukan
tunjukkan tampilan informasi yang dihasilkan
Query yang harus dijawab :
Tampilkan jumlah penjualan di seluruh toko cabang untuk semua produk
dalam satu semester dalam satu semester
Tampilkan produk yang mempunyai penjualan terbesar di toko cabang-1
untuk bulan Maret
Tampilkan rata-rata penjualan setiap produk di toko cabang-2 per triwulan
(tiga bulan)
Tampilkan data penjualan di seluruh toko cabang dari bulan Februari s.d
April
Tampilkan data penjualan di seluruh cabang untuk
Produk 2
46