data war eh house - 1

38
4/30/2012 Data Warehousing 1 Database/OL TP(On-line transaction processing) systems A database is a collection of data associated with some organization or enterprise DBMS is the software used to access a database ER model is often used to abstractly view data of DBMS Relational database is a collection of tables consisting of a set of attributes (fields) and a large set of tuples (records). Relational algebra provides a set of operations that can be performed on relations Database query language SQL is an excellent tool for extracting shallow knowledge from data while data mining discovers hidden knowledge If we know what you are looking for query language can be used  manual data mining

Upload: npdp-here

Post on 07-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 1/38

4/30/2012 Data Warehousing 1

Database/OLTP(On-line transaction processing) systems

A database is a collection of data associated with some

organization or enterpriseDBMS is the software used to access a database

ER model is often used to abstractly view data of DBMS

Relational database is a collection of tables consisting of aset of attributes (fields) and a large set of tuples (records).Relational algebra provides a set of operations that can beperformed on relations

Database query language SQL is an excellent tool forextracting shallow knowledge from data while data miningdiscovers hidden knowledgeIf we know what you are looking for query language can beused – manual data mining

Page 2: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 2/38

4/30/2012 Data Warehousing 2

Data Warehousing/ Dimensional modeling/OLAPsystems

•A decision support database that is maintainedseparately from the organization’s operational

database

•Support information processing by providing asolid platform of consolidated, historical data foranalysis.

•A data warehouse is a Subject-oriented,integrated, time-variant, and non-volatilecollection of data in support of management’s

decision-making process 

Page 3: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 3/38

4/30/2012 Data Warehousing 3

Subject-oriented  – Organized around major subjects such as

customer, supplier, product sales etc.

• Provide a simple and concise view around particular subject 

by excluding data that is not useful for decision process

• Modeled in accordance with decision makers needs and not

transaction processing needs

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, encodingstructures, attribute measures, etc. among different datasources

Page 4: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 4/38

4/30/2012 Data Warehousing 4

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‖ 

Page 5: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 5/38

4/30/2012 Data Warehousing 5

Non-volatile

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, andconcurrency control mechanisms

 – Requires only two operations in data accessing:

•  initial loading of data and• access of data

Page 6: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 6/38

4/30/2012 Data Warehousing 6

Data Warehouse vs. Heterogeneous DBMS

• Traditional heterogeneous DB integration: A query driven approach

 – Build wrappers/mappings on top of heterogeneous databases

 – A meta-dictionary is used to translate the query into queries

appropriate for individual heterogeneous sites involved, and the

results are integrated into a global answer set

 – Complex information filtering, compete for resource

• Data Warehouse : update-driven approach, high performance

 – Information from heterogeneous sources is integrated in advance

and stored in warehouses for direct query and analysis

 – Query processing in DW does not interfere with the processing at

local sources.

Page 7: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 7/384/30/2012 Data Warehousing 7

 Advantages of having a Data warehouse

Provides a competitive advantage by allowing performance

measurement and critical adjustments which helps in

winning over a competitor

Enhance business productivity as the information quickly

available can be used to take corrective action

It facilitates customer relationship management by using

the information across all lines of business, all departments

and all markets.

It brings about cost reduction by tracking trends, patterns

and exceptions in a consistent and reliable manner

To design a warehouse one need to understand and analyze

business needs

Page 8: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 8/384/30/2012 Data Warehousing 8

• OLTP (on-line transaction processing)

 – Major task of traditional relational DBMS

 – Day-to-day operations: purchasing, inventory, banking,

manufacturing, payroll, registration, accounting, etc.• OLAP (on-line analytical processing)

 – Major task of data warehouse system

 – Data analysis and decision making

• 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

Page 9: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 9/384/30/2012 Data Warehousing 9

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 

met ric  transaction throughput  query throughput, response 

Page 10: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 10/384/30/2012 Data Warehousing 10

Why Separate Data Warehouse?

High performance for both systemsDBMS— tuned for OLTP: access methods, indexing,

concurrency control, recoveryWarehouse—tuned for OLAP: complex OLAP queries,multidimensional view, consolidation

Different functions and different data:Missing Data: Decision support requires historical datawhich operational DBs do not typically maintainData Consolidation: DS requires consolidation(aggregation, summarization) of data from heterogeneoussources

Data Quality: different sources typically use inconsistentdata representations, codes and formats which have tobe reconciled

Note: There are more and more systems which perform

OLAP analysis directly on relational databases

Page 11: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 11/384/30/2012 Data Warehousing 11

Multidimensional data modeling

A data warehouse is based on a multidimensional data model which views data in the form of a data cube

A data cube, such as sales, allows data to be modeled andviewed in multiple dimensions.

Dimensions : are the perspectives/entities w. r. to which anorganization wants to keep records

e.g. sales DW - central theme : sales

w. r. to time, item, branch and location

Each dimension - has a table associated with it – dimensiontablee.g., Dimension table for item contain attributes

item_name, brand, type

Page 12: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 12/384/30/2012 Data Warehousing 12

- Theme : represented by fact table- Facts are numerical measures- e.g., amt_sold (total sales amount in Rs.), units_sold (total

no. of units sold)

Note :•  We may display any n-D data as a series of (n-1)  – D“Cubes” 

• Data cubes are n-dimensional & do not confine data to 3-D

In data warehousing literature• an n-D base cube is called a base cuboid (lowest level of

summarization)• The top most 0-D cuboid, which holds the highest-level of

summarization, is called the apex cuboid. (denoted by all)• The lattice of cuboids forms a data cube.• Each cuboid represents a different degree of summarization

Page 13: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 13/384/30/2012 Data Warehousing 13

Lattice of Cuboids

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

time,item 

time,item,location 

time, item, location, supplier 

Page 14: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 14/384/30/2012 Data Warehousing 14

Schemas for Multidimensional Databases :Star schema:

1. A large central table (fact table) containing the bulk of thedata, with no redundancy

2. a set of smaller attendant tables (dimension tables), onefor each dimension

Facts

Dimension 1

Dimension 2

Dimension 3

Dimension 4

Dimension 5

Page 15: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 15/384/30/2012 Data Warehousing 15

Example of Star Schema

time_keyday

day_of_the_week 

month

quarter

year

time

location_key

street

citystate_or_province

country

location

Sales Fact Table

time_key

item_key

branch_key

location_key

units_sold

dollars_sold

avg_sales

Measures

item_key

item_name

brand

type

supplier_type

item

branch_key

branch_name

branch_type

branch

Page 16: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 16/384/30/2012 Data Warehousing 16

Snowflake schema: A refinement of star schema where somedimensional hierarchy is normalized into a set of smallerdimension tables, forming a shape similar to snowflake

The item and location dimensions have been normalized to giverise to two more tables supplier and city

Snowflake vs. star

• saving of storage space and easy to maintain (because of

normalization) is negligible in comparison to the typicalmagnitude of the fact table

• Snowflake structure can reduce the effectiveness of browsing,since more joins are needed to execute a query

• system performance may be adversely impacted

• Snowflake is not as popular as the star schema in DW design

Page 17: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 17/384/30/2012 Data Warehousing 17

Example of Snowflake Schema

time_key

day

day_of_the_week 

month

quarter

year

time

location_key

street

City_key

location

Sales Fact Table

time_key

item_key

branch_key

location_key

units_sold

dollars_sold

avg_sales

Measures

item_key

item_name

brand

type

supplier_key

item

branch_key

branch_namebranch_type

branch

supplier_key

supplier_type

supplier

city_key

city

state_or_province

country

city

F ll i

Page 18: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 18/384/30/2012 Data Warehousing 18

Fact constellations: 

• sophisticated applications may require multiple facttables share dimension tables

• viewed as a collection of stars, therefore calledgalaxy schema or fact constellation

• For DW – Fact constellation schema is commonlyused, since it can model multiple inter-related subjects

• For Data Mart – star or snowflake schema arecommonly used (star schema is more popular andefficient)

hi

Page 19: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 19/384/30/2012 Data Warehousing 19

Example of Fact Constellation

time_key

day

day_of_the_week 

month

quarter

year

time

Sales Fact Table

time_key

item_key

branch_key

location_key

units_sold

dollars_sold

avg_sales

Measures

branch_key

branch_name

branch_type

branch

location_key

street

city

state_or_province

country

location

item_key

item_name

brandtype

supplier_type

item

Sales Fact Table

Sales Fact Table

time_key

item_key

shipper_key

From_location

To_Location

dollars_cost

units_shipped

shipper_key

shipper_name

location_key

shipper_type

shipper

Shipping Fact Table

Page 20: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 20/38

4/30/2012 Data Warehousing 20

Advantages of Star Schema

• The star schema reflects exactly the way the decision

makers thinks in terms of business metrics.• Users understand the structures very easily• It optimizes navigation through the database• It is most suitable for query processing

• It allows query processor software to use betterexecution plans

Disadvantages of Star Schema

• Dimension tables are not normalized leading toredundancy and inconsistency

Page 21: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 21/38

4/30/2012 Data Warehousing 21

In snowflake schema• All tables are fully normalized

Advantages of Snowflake Schema• Small savings in storage space.• Normalized structures are easier to update and maintain

Disadvantages of Snowflake Schema• Schema is less intuitive and end-users are affected by

the complexity• Difficult to browse through contents

• Degraded query performance because of additional joins

E l f d fi i St S fl k d F t

Page 22: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 22/38

4/30/2012 Data Warehousing 22

Examples for defining Star, Snowflake, and FactConstellation Schemas

• data mining query language (DMQL)

2 language primitives

1. cube definition

Syntax :define cube <cube_name> [<dimension_list>] :

<measure_list>

2. Dimension definitionSyntax :

define dimension <dimension_name> as

(<attribute_or_dimension_list>)

St S h d fi iti

Page 23: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 23/38

4/30/2012 Data Warehousing 23

Star Schema definition

Define cube sales_star [time, item, branch, location] :dollars_sold = sum(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)

S fl k S h d fi iti

Page 24: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 24/38

4/30/2012 Data Warehousing 24

Snowflake Schema definition

Define cube sales_snowflake [time, item, branch, location] :dollars_sold = sum(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(supplier_key,supplier_type))

Define dimension branch as (branch_key, branch_name,branch_type)

Define dimension location as (location_key,street,city(city_key, city,province_or_state,country))

• Here item and location tables are normalized

• supplier_key, city_key is implicitly in the item, location dimensionsrespectively

Fact constellation Schema definition

Page 25: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 25/38

4/30/2012 Data Warehousing 25

Fact constellation Schema definition

Define cube sales [time, item, branch, location] : dollars_sold= sum(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)

Page 26: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 26/38

4/30/2012 Data Warehousing 26

Define cube shipping [time, item, shipper, from_location,to_location] : dollars_cost = sum(cost_in_dollars),

units_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

• time, item, location dimensions of the sales cube are shared with theshipping cube

Page 27: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 27/38

4/30/2012 Data Warehousing 27

Page 28: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 28/38

4/30/2012 Data Warehousing 28

Page 29: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 29/38

4/30/2012 Data Warehousing 29

Inside a dimension tableDimension table key- Primary key that uniquelyidentifies rows in the tableTable is wide-has many columns or attributesFewer number of records- fewer rows than facttable-dimension table in hundreds –facts in millions

Textual attributes- attributes are of textual format-they represent textual descriptions of a businessdimensionAttributes not directly related-Some attributes are

not related to one another such as brand andsupplier_type in tem dimension table but both areattributes of item

Page 30: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 30/38

4/30/2012 Data Warehousing 30

Not Normalized- For efficient query performance, itis best if the query takes attributes from dimension

table and goes directly to the fact table. If dimensiontables are normalized, query travels throughintermediary tables affecting performance.Dimension tables are flattened out not normalized in

star schema while some dimensions are normalizedin snowflake schemaDrilling down , Rolling up- The attributes in adimension table provide the ability to get to the

details from higher levels of aggregation to lowerlevels of detailsGet the total sales by city and drill down to totalsales by zip or roll up to total sales by state

Page 31: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 31/38

4/30/2012 Data Warehousing 31

Multiple Hierarchies- Dimension tables oftenprovide for multiple hierarchies so that drilling down

may be performed along any of the multiplehierarchiesThe marketing department may have its own way ofclassifying items by defining item types while theaccounting department may group items by definingits own item types.In this case the item table will contain both the

attributes marketing_item_type andaccounting_item_type

A ib Hi h

Page 32: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 32/38

4/30/2012 Data Warehousing 32

Attribute HierarchyThe attributes may be related by a total order or in some cases apartial order may exist between the attributes of a dimension

week

country

State

city

street

year

quarter

month

daySome attribute hierarchies common to many applications arepredefined ex. Time. While some are user-defined

Attribute hierarchies may be provided by domain experts orgenerated automatically by statistical analysis of data distribution

Page 33: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 33/38

4/30/2012 Data Warehousing 33

Inside the fact TableConcatenated keys A row in the fact table relates to

a combination of rows from all the dimension table.The primary key of the fact table is theconcatenation of the primary keys of all thedimension tables

Data Grain- The data grain is the level of detail forthe measurement or metrics. The quantity sold canbe of a particular item on a given date to a givencustomer(if customer dimension is also added)which is at a very detailed level.The data grain in this case is at a higher level

Page 34: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 34/38

4/30/2012 Data Warehousing 34

Fully Additive measures The values can be summed upby simple additionSemi Additive measures- Derived attributes such as

dollars earned per quantity is not additive.Distinguish semi additive measures from fully additivemeasures when performing aggregation in queriesTable deep, not wide- Fewer attributes than a dimension

table , but large number of rows .Fact table is narrow but deep. Fact table is spreadvertically while dimension table is spread horizontallySparse data-There could be combinations of dimension

table attributes for which fact table entry may be nullDegenerate dimensions- these are some attributessuch sales_order_no which appear in fact table thoughthese are not measures –useful for analysis such as

average number of items per order

Page 35: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 35/38

4/30/2012 Data Warehousing 35

Typical OLAP OperationsRoll up (drill-up): summarize data

by climbing up hierarchy or by dimension reduction  

•Drill down (roll down): reverse of roll-upfrom higher level summary to lower level summary or detailed data, or introducing new dimensions 

•Slice and dice: project and select  Slice-selection on one dimension of cube resulting in a

subcubeDice-selection operation on two or more dimensions•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) 

Page 36: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 36/38

4/30/2012 Data Warehousing 36

Page 37: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 37/38

4/30/2012 Data Warehousing 37

Conceptual Modeling of Data Warehouses

• Criteria for dimensional model• The model should provide the best data access• The whole model should be queri-centric• It must be optimized for queries and analysis

• It must be structured in such a way that everydimension can interact equally with the fact table• The model should allow drilling down or rolling upalong dimension hierarchies

DimensionsTime , location , item , branchFactsQuantity of sales, Sales Amount,

Page 38: Data War Eh House - 1

8/3/2019 Data War Eh House - 1

http://slidepdf.com/reader/full/data-war-eh-house-1 38/38

Conceptual Modeling of Data Warehouses

Design DecisionsChoosing the process – selecting the subjects forthe first set of logical structures to be designed

Choosing the grain- determining the level of detail

for the data in the data structuresIdentifying and conforming the dimensions-

choosing the dimensions to be includedChoosing the facts-Selecting the metrics or units of

measurements to be includedChoosing the duration of the database- determining

how far back in time one should go forhistorical data