Module 1 Part1 DataWarehouse Architecture, Schema
Module 1 Part1 DataWarehouse Architecture, Schema
Data Warehouse
1/29/2023
1/29/2023 https://www.geeksforgeeks.org/difference-between-rdbms-and-dbms/
What is a data warehouse?
1/29/2023
1/29/2023
• Defined in many different ways
• 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.
• Data warehousing:
• The process of constructing and using data warehouses
1/29/2023
• 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.
1/29/2023
• 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.
1/29/2023
• 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”.
1/29/2023
• 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.
1/29/2023
1/29/2023
1/29/2023
• Distinct features (OLTP vs. OLAP):
• User and system orientation: customer vs. market
• Data contents: current, detailed vs. historical, consolidated
• Database design: ER + application vs. star + subject
• View: current, local vs. evolutionary, integrated
• Access patterns: update vs. read-only but complex queries
1/29/2023
• OLTP (on-line transaction processing)
• Major task of traditional relational DBMS
• Day-to-day operations: purchasing, inventory, banking,
manufacturing, payroll, registration, accounting, etc.
1/29/2023
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 historical,
detailed, flat relational summarized, multidimensional
isolated integrated, consolidated
usage repetitive ad-hoc
access read/write lots of scans
index/hash on prim. key
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
1/29/2023
• High performance for both systems
1/29/2023
• 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(Made
compatible or consistent)
1/29/2023
A multi-dimensional data model
1/29/2023
1/29/2023
1/29/2023
1/29/2023
all
0-D(apex) cuboid
time,location,supplier
time,item,location 3-D cuboids
time,item,supplier item,location,supplier
4-D(base) cuboid
1/29/2023 time, item, location, supplier
• What is Data Cube?
• What is Dimension Table?
• What is Fact Table?
• What is Base Cuboid?
• What is Apex Cuboid?
1/29/2023
• 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
1/29/2023
1/29/2023
1/29/2023
time
time_key item
day item_key
day_of_the_week Sales Fact Table item_name
month brand
quarter time_key type
year supplier_type
item_key
branch_key
branch location
location_key
branch_key location_key
branch_name units_sold street
branch_type city
dollars_sold province_or_street
country
avg_sales
Measures
1/29/2023
time
time_key item
day item_key supplier
day_of_the_week Sales Fact Table item_name supplier_key
month brand supplier_type
quarter time_key type
year item_key supplier_key
branch_key
branch location
location_key
location_key
branch_key
units_sold street
branch_name
city_key
branch_type city
dollars_sold
city_key
avg_sales city
Measures province_or_street
country
1/29/2023
time
time_key item Shipping Fact Table
day item_key
day_of_the_week Sales Fact Table item_name time_key
month brand
quarter time_key type item_key
year supplier_type shipper_key
item_key
branch_key from_location
1/29/2023
define cube sales_snowflake [time, item, branch, location]:
dollars_sold = sum(sales_in_dollars), avg_sales = avg(sales_in_dollars),
units_sold = count(*)
1/29/2023
define dimension branch as (branch_key, branch_name,
branch_type)
define dimension location as (location_key, street, city(city_key,
province_or_state, country))
1/29/2023
define cube sales [time, item, branch, location]:
dollars_sold = sum(sales_in_dollars), avg_sales = avg(sales_in_dollars),
units_sold = count(*)
define dimension time as (time_key, day, day_of_week, month, quarter,
year)
define dimension item as (item_key, item_name, brand, type,
supplier_type)
define dimension branch as (branch_key, branch_name, branch_type)
define dimension location as (location_key, street, city,
province_or_state, country)
1/29/2023
define cube shipping [time, item, shipper, from_location,
to_location]:
dollar_cost = sum(cost_in_dollars), unit_shipped = count(*)
define dimension time as time in cube sales
define dimension item as item in cube sales
define dimension shipper as (shipper_key, shipper_name, location
as location in cube sales, shipper_type)
define dimension from_location as location in cube sales
define dimension to_location as location in cube sales
1/29/2023
• Based on aggregate functions used.
• 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().
1/29/2023
all all
1/29/2023
• Sales volume as a function of product, month, and region
Office Day
Month
1/29/2023
Date Total annual sales
1Qtr 2Qtr 3Qtr 4Qtr sum of TV in U.S.A.
TV
PC U.S.A
VCR
Country
sum
Canada
Mexico
sum
1/29/2023
all
0-D(apex) cuboid
product date country
1-D cuboids
3-D(base) cuboid
product, date, country
1/29/2023
• Roll up (drill-up): summarize data
• by climbing up hierarchy or by dimension reduction
1/29/2023
• 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)
1/29/2023
Data warehouse architecture
1/29/2023
1. The design of a data warehouse: a business analysis
framework
2. The process of data warehouse design
3. A three-tier data ware house architecture
1/29/2023
• Four views regarding the design of a data warehouse
• Top-down view
1/29/2023
• Data warehouse view
• consists of fact tables and dimension tables
1/29/2023
• Top-down, bottom-up approaches or a combination of
both
• Top-down: Starts with overall design and planning (mature)
• Bottom-up: Starts with experiments and prototypes (rapid)
• From software engineering point of view
• Waterfall: structured and systematic analysis at each step
before proceeding to the next
• Spiral: rapid generation of increasingly functional systems,
short turn around time, quick turn around
1/29/2023
• Typical data warehouse design process
• Choose a business process to model, e.g., orders, invoices, etc.
• Choose the grain (atomic level of data) of the business process
• Choose the dimensions that will apply to each fact table record
• Choose the measure that will populate each fact table record
1/29/2023
Multi-Tiered Architecture
Monitor
& OLAP Server
other Metadata
Integrator
sources
Analysis
Operational Extract Query
Transform Serve
DBs Data Reports
Load
Refresh
Warehouse Data mining
Data Marts
Data Sources
1/29/2023 Data Storage OLAP Engine Front-End Tools
• Meta data is the data defining warehouse objects. It has the
following kinds
• Description of the structure of the warehouse
• schema, view, dimensions, hierarchies, derived data defn, data mart locations and
contents
• Operational meta-data
• data lineage (history of migrated data and transformation path), currency of
data (active, archived, or purged), monitoring information (warehouse usage
statistics, error reports, audit trails)
• The algorithms used for summarization
• The mapping from operational environment to the data warehouse
• Data related to system performance
• warehouse schema, view and derived data definitions
• Business data
• business terms and definitions, ownership of data, charging policies
1/29/2023
• 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 indices and partitions
• Refresh
• propagate the updates from the data sources to the
warehouse
1/29/2023
• Enterprise warehouse
–collects all of the information about subjects spanning the entire
organization
• Data Mart
–a subset of corporate-wide data that is of value to a specific
groups of users. Its scope is confined to specific, selected
groups, such as marketing data mart
• Independent vs. dependent (directly from warehouse) data mart
• Virtual warehouse
–A set of views over operational databases
–Only some of the possible summary views may be materialized
1/29/2023
Multi-Tier Data
Warehouse
Distributed
Data Marts
1/29/2023
Define a high-level corporate data model
• Relational OLAP (ROLAP)
• Use relational or extended-relational DBMS to store and
manage warehouse data and OLAP middle ware to support
missing pieces
• Include optimization of DBMS backend, implementation of
aggregation navigation logic, and additional tools and
services
• greater scalability
• Multidimensional OLAP (MOLAP)
• Array-based multidimensional storage engine (sparse matrix
techniques)
• fast indexing to pre-computed summarized data
1/29/2023
• Hybrid OLAP (HOLAP)
• User flexibility, e.g., low level: relational, high-level: array
• Specialized SQL servers
• specialized support for SQL queries over star/snowflake schemas
1/29/2023
1/29/2023
Q. Suppose that a data warehouse consists of the three dimensions time, doctor,
and patient, and the two measures count and charge, where charge is the fee
that a doctor charges a patient for a visit.
(a) Enumerate three classes of schemas that are popularly used for
modeling data warehouses.
(b) Draw a schema diagram for the above data warehouse using one
of the schema classes listed in (a).
(c) Starting with the base cuboid [day, doctor, patient], what specific OLAP
operations should be performed in order to list the total fee collected by each
doctor in 2004?
(d) To obtain the same list, write an SQL query assuming the data is stored in a
relational database with the schema fee (day, month, year, doctor, hospital,
patient, count, charge ).
1/29/2023
PRACTICE QUESTION:
Suppose that a data warehouse for Big-University consists of the following four
dimensions: student, course, semester, and instructor, and two measures count
and avg grade. When at the lowest conceptual level (e.g., for a given student,
course, semester, and instructor combination), the avg grade measure stores the
actual course grade of the student. At higher conceptual levels, avg grade
stores the average grade for the given combination.
(a) Draw a snowflake schema diagram for the data warehouse.
(b) Starting with the base cuboid [student, course, semester, instructor], what
specific OLAP operations (e.g., roll-up from semester to year ) should one
perform in order to list the average grade of CS courses for each Big-
University student.
(c) If each dimension has five levels (including all), such as “student < major <
status < university < all”, how many cuboids will this cube contain (including the
base and apex cuboids)?
1/29/2023