Upload
charlotte-stewart
View
217
Download
0
Tags:
Embed Size (px)
Citation preview
Data Warehousing and Decision Support
courtesy of Jiawei Han, Larry Kerschberg, and etc.
for some slides.
Jianlin FengSchool of SoftwareSUN YAT-SEN UNIVERSITY
April 19, 2023Data Mining: Concepts and
Techniques 2
Outline
Data Warehouse: Basic Concepts
Data Warehouse Modeling: Data Cube and
OLAP
Summary
April 19, 2023Data Mining: Concepts and
Techniques 3
What is a Data Warehouse?
Defined in many different ways, but not rigorously.
A decision support database that is maintained separately from
the organization’s operational database
Support information processing by providing a solid platform of
consolidated, historical data for analysis.
“A data warehouse is a subject-oriented, integrated, time-variant,
and nonvolatile collection of data in support of management’s
decision-making process.”—W. H. Inmon
Data warehousing:
The process of constructing and using data warehouses
April 19, 2023Data Mining: Concepts and
Techniques 4
Data Warehouse—Subject-Oriented
Organized around major subjects, such as customer,
product, sales
Focusing on the modeling and analysis of data for
decision makers, not on daily operations or transaction
processing
Provide a simple and concise view around particular
subject issues by excluding data that are not useful in the
decision support process
April 19, 2023Data Mining: Concepts and
Techniques 5
Data Warehouse—Integrated
Constructed by integrating multiple, heterogeneous data sources relational databases, flat files, on-line transaction
records Data cleaning and data integration techniques are
applied. Ensure consistency in naming conventions, encoding
structures, attribute measures, etc. among different data sources E.g., Hotel price: currency, tax, breakfast covered, etc.
When data is moved to the warehouse, it is converted.
April 19, 2023Data Mining: Concepts and
Techniques 6
Data Warehouse—Time Variant
The time horizon for the data warehouse is significantly
longer than that of operational systems
Operational database: current value data
Data warehouse data: provide information from a
historical perspective (e.g., past 5-10 years)
Every key structure in the data warehouse
Contains an element of time, explicitly or implicitly
But the key of operational data may or may not contain
“time element”
April 19, 2023Data Mining: Concepts and
Techniques 7
Data Warehouse—Nonvolatile
A physically separate store of data transformed from the
operational environment
Operational update of data does not occur in the data
warehouse environment
Does not require transaction processing, recovery,
and concurrency control mechanisms
Requires only two operations in data accessing:
initial loading of data and access of data
April 19, 2023Data Mining: Concepts and
Techniques 8
OLTP vs. OLAP OLTP OLAP
users clerk, IT professional knowledge worker
function day to day operations decision support
DB design application-oriented subject-oriented
data current, up-to-date detailed, flat relational isolated
historical, summarized, multidimensional integrated, consolidated
usage repetitive ad-hoc
access read/write index/hash on prim. key
lots of scans
unit of work short, simple transaction complex query
# records accessed tens millions
#users thousands hundreds
DB size 100MB-GB 100GB-TB
metric transaction throughput query throughput, response
April 19, 2023Data Mining: Concepts and
Techniques 9
Why a Separate Data Warehouse? High performance for both systems
DBMS— tuned for OLTP: access methods, indexing, concurrency control, recovery
Warehouse—tuned for OLAP: complex OLAP queries, multidimensional view, consolidation
Different functions and different data: missing data: Decision support requires historical data which
operational DBs do not typically maintain data consolidation: DS requires consolidation (aggregation,
summarization) of data from heterogeneous sources data quality: different sources typically use inconsistent data
representations, codes and formats which have to be reconciled Note: There are more and more systems which perform OLAP analysis
directly on relational databases
April 19, 2023Data Mining: Concepts and
Techniques 10
Data Warehouse: A Multi-Tiered ArchitectureData Warehouse: A Multi-Tiered Architecture
DataWarehouse
ExtractTransformLoadRefresh
OLAP Engine
AnalysisQueryReportsData mining
Monitor&
Integrator
Metadata
Data Sources Front-End Tools
Serve
Data Marts
Operational DBs
Othersources
Data Storage
OLAP Server
April 19, 2023Data Mining: Concepts and
Techniques 11
Extraction, Transformation, and Loading (ETL) Data extraction
get data from multiple, heterogeneous, and external sources Data cleaning
detect errors in the data and rectify them when possible Data transformation
convert data from legacy or host format to warehouse format Load
sort, summarize, consolidate, compute views, check integrity, and build indicies and partitions
Refresh propagate the updates from the data sources to the
warehouse
April 19, 2023Data Mining: Concepts and
Techniques 12
Outline
Data Warehouse: Basic Concepts
Data Warehouse Modeling: Data Cube and
OLAP
Data Warehouse Design and Usage
Data Warehouse Implementation
Summary
Data Cube Concept
Data Cube: A Relational Aggregation Operator Generalizing Group-By, Cross-Tab and Sub-Totals By Jim Gray et al, in IEEE ICDE’1996
CUBE: A Relational Aggregate Operator Generalizing Group By (from Gray, et al)CUBE: A Relational Aggregate Operator Generalizing Group By (from Gray, et al)
CHEVY
FORD 19901991
19921993
REDWHITEBLUE
By Color
By Make & Color
By Make & Year
By Color & Year
By MakeBy Year
Sum
The Data Cube and The Sub-Space Aggregates
REDWHITE
BLUE
Chevy Ford
By Make
By Color
Sum
Cross TabRED
WHITE
BLUE
By Color
Sum
Group By (with total)Sum
Aggregate
Data Analysis Tasks
Formulate a query to extract relevant information
Extract the aggregated data from the database into a file.
Visualize the result to look for patterns. Analyze the result and perhaps formulate
new queries.
Goal of the Cube
Represent N-dimensional data cubes using 2-D relations
Compute the aggregate information within the database,
Create language extensions to SQL that will support the required operations.
Relational Representation of N-Dimensional Data
Weather information consists of four dimensions: Time, Latitude, Longitude and Altitude
Measured variables are Temperature and Pressure.
SQL 1992 Standard supports aggregation functions:
•Count (), Sum(), Min(), Max() and AVE(); Some SQL
systems have Median, Standard Deviation, variance, etc.
•SELECT AVE(Temp) FROM Weather
•SELECT COUNT(DISTINCT Time) FROM Weather
SELECT Time, Altitude, AVE(Temp)
FROM Weather
GROUP BY Time, Altitude
Group-By Operation and Aggregates
Group-By operation defines an equivalence relation on a table, partitioning the tuples in classes having the same attribute values.
Each group can then be aggregated.
TCP-D has one 6D GROUP BY and three 3D GROUP Bys.
Problems with GROUP-BY
Group-By cannot directly construct: Histograms, Roll-up Totals, Sub-totals for Drill-downs, and Cross Tabulations.
Roll-Ups and Sub-Totals for Drill-Down
Tables 3a, 3b, and 4 show Sales Roll Up by Model by Year by Color and an Excel Pivot Table with this information
Roll-Ups and Sub-Totals for Drill-Down
Excel Pivot Table
Sales Summary Roll Up in Table 5a and 5b for Chevy over all color and years (Note the ALL value)
Cube: Each Attribute is a DimensionCube: Each Attribute is a Dimension
N-dimensional Aggregate (sum(), max(),...) Fits relational model exactly:
a1, a2, ...., aN, f()
Super-aggregate over N-1 Dimensional sub-cubes ALL, a2, ...., aN , f() a1 , ALL, a3, ...., aN , f() ... a1, a2, ...., ALL, f()
This is the N-1 Dimensional cross-tab. Super-aggregate over N-2 Dimensional sub-cubes
ALL, ALL, a3, ...., aN , f() ... a1, a2 ,...., ALL, ALL, f()
Sub-cube Derivation
Dimension collapse, * denotes ALL
<M,Y,C>
<M,Y,*> <M,*,C> <*,Y,C>
<M,*,*> <*,Y,*><*,*,C>
<*,*,*>
Cube Operator ExampleCube Operator Example SALES Model Year Color Sales Chevy 1990 red 5 Chevy 1990 white 87 Chevy 1990 blue 62 Chevy 1991 red 54 Chevy 1991 white 95 Chevy 1991 blue 49 Chevy 1992 red 31 Chevy 1992 white 54 Chevy 1992 blue 71 Ford 1990 red 64 Ford 1990 white 62 Ford 1990 blue 63 Ford 1991 red 52 Ford 1991 white 9 Ford 1991 blue 55 Ford 1992 red 27 Ford 1992 white 62 Ford 1992 blue 39
DATA CUBE Model Year Color Sales ALL ALL ALL 942 chevy ALL ALL 510 ford ALL ALL 432 ALL 1990 ALL 343 ALL 1991 ALL 314 ALL 1992 ALL 285 ALL ALL red 165 ALL ALL white 273 ALL ALL blue 339 chevy 1990 ALL 154 chevy 1991 ALL 199 chevy 1992 ALL 157 ford 1990 ALL 189 ford 1991 ALL 116 ford 1992 ALL 128 chevy ALL red 91 chevy ALL white 236 chevy ALL blue 183 ford ALL red 144 ford ALL white 133 ford ALL blue 156 ALL 1990 red 69 ALL 1990 white 149 ALL 1990 blue 125 ALL 1991 red 107 ALL 1991 white 104 ALL 1991 blue 104 ALL 1992 red 59 ALL 1992 white 116 ALL 1992 blue 110
CUBE
Interesting Aggregate Functions From RedBrick systems
Rank (in sorted order) N-Tile (histograms) Running average (cumulative functions) Windowed running average Percent of total
Users want to define their own aggregate functions statistics domain specific
April 19, 2023Data Mining: Concepts and
Techniques 27
Conceptual Modeling of Data Warehouses
Modeling data warehouses: dimensions & measures
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 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
April 19, 2023Data Mining: Concepts and
Techniques 28
Example of Star Schema
time_keydayday_of_the_weekmonthquarteryear
time
location_keystreetcitystate_or_provincecountry
location
Sales Fact Table
time_key
item_key
branch_key
location_key
units_sold
dollars_sold
avg_sales
Measures
item_keyitem_namebrandtypesupplier_type
item
branch_keybranch_namebranch_type
branch
April 19, 2023Data Mining: Concepts and
Techniques 29
Example of Snowflake Schema
time_keydayday_of_the_weekmonthquarteryear
time
location_keystreetcity_key
location
Sales Fact Table
time_key
item_key
branch_key
location_key
units_sold
dollars_sold
avg_sales
Measures
item_keyitem_namebrandtypesupplier_key
item
branch_keybranch_namebranch_type
branch
supplier_keysupplier_type
supplier
city_keycitystate_or_provincecountry
city
April 19, 2023Data Mining: Concepts and
Techniques 30
Example of Fact Constellation
time_keydayday_of_the_weekmonthquarteryear
time
location_keystreetcityprovince_or_statecountry
location
Sales Fact Table
time_key
item_key
branch_key
location_key
units_sold
dollars_sold
avg_sales
Measures
item_keyitem_namebrandtypesupplier_type
item
branch_keybranch_namebranch_type
branch
Shipping Fact Table
time_key
item_key
shipper_key
from_location
to_location
dollars_cost
units_shipped
shipper_keyshipper_namelocation_keyshipper_type
shipper
April 19, 2023Data Mining: Concepts and
Techniques 31
A Concept Hierarchy: Dimension (location)
all
Europe North_America
MexicoCanadaSpainGermany
Vancouver
M. WindL. Chan
...
......
... ...
...
all
region
office
country
TorontoFrankfurtcity
April 19, 2023Data Mining: Concepts and
Techniques 32
Data Cube Measures: Three Categories
Distributive: if the result derived by applying the function to n aggregate values is the same as that derived by applying the function on all the data without partitioning
E.g., count(), sum(), min(), max()
Algebraic: if it can be computed by an algebraic function with M arguments (where M is a bounded integer), each of which is obtained by applying a distributive aggregate function
E.g., avg(), min_N(), standard_deviation()
Holistic: if there is no constant bound on the storage size needed to describe a subaggregate.
E.g., median(), mode(), rank()
April 19, 2023Data Mining: Concepts and
Techniques 33
Typical OLAP Operations over Data Cube
Roll up (drill-up): summarize data by climbing up hierarchy or by dimension reduction
Drill down (roll down): reverse of roll-up from higher level summary to lower level summary or
detailed data, or introducing new dimensions Slice and dice: project and select Pivot (rotate):
reorient the cube, visualization, 3D to series of 2D planes Other operations
drill across: involving (across) more than one fact table drill through: through the bottom level of the cube to its
back-end relational tables (using SQL)
April 19, 2023Data Mining: Concepts and
Techniques 34
Definition of Cube Operation A new operator cube by, introduced by Gray et al.’96
SELECT item, city, year, SUM (amount)
FROM SALES
CUBE BY item, city, year
Need compute the following Group-Bys
(date, product, customer),
(date,product),(date, customer), (product, customer),
(date), (product), (customer)
()
(item)(city)
()
(year)
(city, item) (city, year) (item, year)
(city, item, year)
April 19, 2023Data Mining: Concepts and
Techniques 35
Cube: A Lattice of Cuboids
time,item
time,item,location
time, item, location, supplier
all
time item location supplier
time,location
time,supplier
item,location
item,supplier
location,supplier
time,item,supplier
time,location,supplier
item,location,supplier
0-D (apex) cuboid
1-D cuboids
2-D cuboids
3-D cuboids
4-D (base) cuboid
April 19, 2023Data Mining: Concepts and
Techniques 36
Iceberg Cube
Computing only the cuboid cells whose count or other aggregates satisfy a condition with minimum support, e.g.
HAVING COUNT(*) >= minsup
April 19, 2023Data Mining: Concepts and
Techniques 37
Indexing OLAP Data: Bitmap Index Index on a particular column
Each value in the column has a bit vector: bit-op is fast The length of the bit vector: # of records in the base table The i-th bit is set if the i-th row of the base table has the value for the
indexed column A recent bit compression technique, Word-Aligned Hybrid (WAH),
makes it work for high cardinality domain as well [Wu, et al. TODS’06]
Cust Region TypeC1 Asia RetailC2 Europe DealerC3 Asia DealerC4 America RetailC5 Europe Dealer
RecID Retail Dealer1 1 02 0 13 0 14 1 05 0 1
RecID Asia Europe America1 1 0 02 0 1 03 1 0 04 0 0 15 0 1 0
Base table Index on Region Index on Type
April 19, 2023Data Mining: Concepts and
Techniques 38
Indexing OLAP Data: Join Indices Join index:
JI(R-id, S-id) where R (R-id, …) S (S-id, …)
In data warehouses, join index relates the values of the dimensions of a star schema to rows in the fact table. E.g. fact table: Sales and two dimensions
city and product A join index on city maintains for each
distinct city a list of R-IDs of the tuples recording the Sales in the city
Join indices can span multiple dimensions
April 19, 2023Data Mining: Concepts and
Techniques 39
Efficient Processing OLAP Queries
Determine which operations should be performed on the available cuboids
Transform drill, roll, etc. into corresponding SQL and/or OLAP operations,
e.g., dice = selection + projection
Determine which materialized cuboid(s) should be selected for OLAP op.
Let the query to be processed be on {brand, province_or_state} with the
condition “year = 2004”, and there are 4 materialized cuboids available:
1) {year, item_name, city}
2) {year, brand, country}
3) {year, brand, province_or_state}
4) {item_name, province_or_state} where year = 2004
Which should be selected to process the query?
Explore indexing structures and compressed vs. dense array structs in MOLAP
April 19, 2023Data Mining: Concepts and
Techniques 40
OLAP Server Architectures Relational OLAP (ROLAP)
Use relational or extended-relational DBMS to store and manage warehouse data and OLAP middle ware
Include optimization of DBMS backend, implementation of aggregation navigation logic, and additional tools and services
Greater scalability Multidimensional OLAP (MOLAP)
Sparse array-based multidimensional storage engine Fast indexing to pre-computed summarized data
Hybrid OLAP (HOLAP) (e.g., Microsoft SQLServer) Flexibility, e.g., low level: relational, high-level: array
Summary
Decision support is an emerging, rapidly growing subarea of databases.
Involves the creation of large, consolidated data repositories called data warehouses.
Warehouses exploited using sophisticated analysis techniques: complex SQL queries and OLAP “multidimensional”queries (influenced by both SQL and spreadsheets).
New techniques for database design, indexing, view maintenance, and interactive querying need to be supported.