Principles of Data Warehousing Lecturer Dr Bo Yuan
Principles of Data Warehousing Lecturer: Dr. Bo Yuan LOGO E-mail: yuanb@sz. tsinghua. edu. cn
Outline OLAP Metadata Data Warehouse ETL Data Marts Multidimensional Data 2
A Manager’s Questions … Who are our lowest or highest margin customers ? Who are my customers and what products are they buying? What is the most effective distribution channel? Which customers are most likely to go to the competition ? What promotions have the biggest impact on revenue? What impact will new products/services have on revenue and margins? 3
Tourists, Farmers and Explorers Tourists: Browse information harvested by farmers. Farmers: Harvest information from known access paths. Explorers: Seek out the unknown and previously unsuspected rewards hiding in the detailed data. 4
History & Evolution v 60’s: Batch Reports § Hard to find analyze information § Inflexible and expensive, reprogram every new request v 70’s: Terminal-Based DSS and EIS § Still inflexible, not integrated with desktop tools v 80’s: Desktop Data Access and Analysis Tools § Query tools, Spreadsheets, GUIs § Easier to use, but only access operational databases v 90’s: Data Warehousing § OLAP Engines and Tools 5
Data Everywhere v I cannot find the data I need. § Data are scattered over the network. § Many versions v I cannot get the data I need. § May need experts to get the data. v I cannot understand the data I found. § Poorly documented § Domain knowledge v I cannot use the data I found. § Quality § Transformation 6
What is a data warehouse? “A single, complete and consistent store of data obtained from a variety of different sources made available to end users in a way that they can understand use in a business context. ” 7
What is data warehousing? v Data warehousing: techniques for assembling and managing data from various sources for the purpose of answering business questions and making decisions. v A data warehouse is a collection of data that is used primarily in organizational decision making. v A data warehouse is § § Knowledge Subject-oriented Integrated Time-varying Non-volatile Data 8 Information
Data Warehouse Architecture Relational Databases Optimized Loader ERP Systems Extraction Cleansing Data Warehouse Engine Purchased Data Legacy Data Metadata Repository 9 Analyze Query
Data Warehouse is … v Subject-Oriented § The data warehouse is organized around subjects of the enterprise (e. g. , customers, products, sales) rather than applications areas (e. g. , customer invoicing, stock control, product sales). § This is reflected in the need to store decision-support data instead of application-oriented or operational data. v Integrated § The data warehouse integrates corporate application-oriented data from different sources, which often include inconsistent data. § The integrated data sources must be made consistent to present a unified view of the data to the users. 10
Data Warehouse is … v Time-Variant § Data warehouses are time variant in the sense that they maintain both historical and (nearly) current data. § Historical information is of high importance to decision makers, who often want to understand trends and relationships between data. v Non-Volatile § After the data are loaded into the data warehouse, there are no changes, inserts, or deletes performed against the historical data. § This is logical because the purpose of a warehouse is to enable you to analyze what has occurred. 11
Operational Systems v Operational Systems § Run the business in real time. § Based on up-to-the-second data. § Optimized to handle large numbers of simple read/write transactions. § Optimized for fast response to predefined transactions. § Used by people who deal with customers, products. v Database systems have been used traditionally for OLTP. § Online Transaction Processing § Clerical data processing tasks § Detailed, up to date data § Structured repetitive tasks v Examples of Operational Data § Customer Files § Account Balance, Call Record § Point of Sale Data, Production Record 12
Data Warehousing vs. OLTP v Workload § Data warehouses are designed to accommodate ad hoc queries. A data warehouse should be optimized to perform well for a wide variety of possible query operations. § OLTP systems support only predefined operations and might be specifically tuned or designed to support only these operations. v Data Modifications § A data warehouse is updated on a regular basis by the ETL process (run nightly or weekly) using bulk data modification techniques. The users of a data warehouse do not directly update the data warehouse. § In OLTP systems, users routinely issue individual data modification statements to the database. The OLTP database is always up to date, and reflects the current state of each business transaction. 13
Data Warehousing vs. OLTP v Schema Design § Data warehouses often use denormalized or partially denormalized schemas (such as a star schema) to optimize query performance. § OLTP systems often use fully normalized schemas to optimize update/insert/delete performance, and to guarantee data consistency. v Typical Operations § A typical data warehouse query scans thousands or millions of rows. For example, "Find the total sales for all customers last month. " § A typical OLTP operation accesses only a handful of records. For example, "Retrieve the current order for this customer. " 14
Data Warehousing vs. OLTP v Historical Data § Data warehouses usually store months or years of data to support historical analysis. § OLTP systems usually store data from only a few weeks or months to meet the requirements of the current transaction. v Number of Users § Data Warehouses: hundreds of users. § OLTP Systems : tens of thousands users. v Database Size § Data Warehouses: 10 GB - 1 TB § OLTP Systems: 100 M - 10 GB 15
In summary … Data warehousing helps optimize the business. OLTP systems actually run the business. 16
Data Marts v A data mart is a subset of an organizational data store, usually oriented to a specific purpose or major data subject, that may be distributed to support business needs. v Departmental Data Warehouse v A data warehouse tends to be a strategic but somewhat unfinished concept; a data mart tends to be tactical and aimed at meeting an immediate need. v The smaller-scale data mart is typically easier to build than the enterprise-wide warehouse; can be quickly implemented; and offers tremendous, fast payback for the users. v The downside comes when several department-focused data marts are implemented with no forethought for a future data warehouse that serves the entire enterprise. 17
Independent Data Marts 18
Dependent Data Marts 19
Data Granularity v Granularity is the extent to which a system is broken down into small parts, either the system itself or its description or observation. v A key factor to consider in the design of data warehouses. v The amount of data to be stored in the data warehouse. v Operational Databases § Transaction Oriented § Detailed Records Lowest Level of Granularity § The details of the phone call made by Tom at 2: 40 pm yesterday v Data Warehouses § Decision Making § Summarized Data High Levels of Granularity § The number of phone calls made by Tom last month 20
Data Granularity 21
Data Granularity v High Levels of Granularity § Reduce storage costs. § Reduce CPU usage. § Cannot answer certain queries. • Did Tom call Mary last week? § A tradeoff between the volume and the usage of data. v Dual Levels of Granularity § Store summarized data on disks. • Cover 95% decision making queries. • Data access is cheap and convenient. § Store detailed data on tapes. • Cover 5% decision making queries. • Many records need to be involved to process a query. • Data access is expensive and complicated. § Many levels of granularity may be necessary in practice. 22
Data Partition Acct. No Name Balance Date Opened Interest Rate Address Frequently Accessed Acct. No Balance Acct. No Name Date Opened Interest Rate Address Rarely Accessed Smaller Table & Less I/O 23
Data Quality v Data warehouses are based on existing data sources. v Data quality matters! v Creating a data warehouse is not a straightforward process. v Warehouse data are from disparate and questionable sources. v Legacy systems are no longer documented. v Corporate wide standards are not well implemented. v Advanced techniques and tools are needed to do the job. 24
10 Minutes … 25
Extract, Transform & Load v Extract, Transform & Load (ETL) § The interface between external sources and data warehouses § ETL may take around 70% of the total workload. § Can be implemented manually in any programming language. § Commercial ETL tools are widely available. v Extract § To consolidate data from different source systems. • • • Flat Files Relational Databases Customized Applications Point of Sale Devices Web Pages § To locate the sources for each data item in the data warehouse. • Not all data are to be extracted. 26
Extract, Transform & Load v Transform § To apply a series of rules or functions to the extracted data to derive the data for loading into the end target. § Typical Functions • • Formatting Encoding Aggregating Splitting Deriving Converting Integrating v Load § To load the extracted, cleaned and validated data into the end target. • Online vs. Offline Loads • Incremental vs. Full Loads 27
ETL --- Challenges Savings Same data different name Trust Loans Different data same name Credit Card Inconsistent name or data 28
ETL --- Challenges encoding appl A - m, f B - 1, 0 C - x, y D - male, female unit appl A - pipeline - cm B - pipeline - in C - pipeline - feet D - pipeline - yds field External Sources appl A - balance B - bal C - currbal D - balcurr Data Warehouse 29
ETL --- Challenges v Same person, different spellings § �: LV, LUI, LYU v Multiple ways to denote company name § Global Systems, GSPL, Global Pty. LTD. v Use of different names for the same object/concept § Holland vs. Netherland v Inconsistent data values § Age, Marital Status … v Required fields left blank § Missing Values v Invalid product codes collected at point of sale § Manual entry leads to mistakes. § Different conventions: using “-1” or “ 99999” to indicate an error 30
Metadata v Metadata is information about data. v Metadata is used to facilitate the understanding, characteristics, and management usage of data. v Metadata can document data about data attributes & structure. v Metadata may include descriptive information about the context, quality and condition, or characteristics of the data. v Metadata for a Book § Title, Author, Subject, ISBN, Number of Pages … v Metadata for a data warehouse § The data defining warehouse objects § A roadmap telling users what are in there and how to find them § Far more sophisticated than a data dictionary 31
Metadata Repository v Data definition and mapping metadata § The meaning of each attribute and where the data come from v Data structure metadata § The structure of the tables (the data type of each column, primary/foreign key) v Source system metadata § The data structure of all the source systems feeding in the warehouse v ETL process metadata § The description of each data flow (source, target, transformation, schedule) v Data quality metadata § Data quality rules and where they are applicable for, their risk level and actions v Audit metadata § The results of all processes (ETL, security log, indexing) in the warehouse v Usage metadata § Records about which reports and cubes are used by who and when 32
Data Models in Data Warehouses v In OLTP systems, data are stored in 2 D matrixes. v Data warehouses are subject-oriented § Profits, Sales … § Data need to be reorganized to better reflect the subjects. v A data warehouse is based on a multidimensional data model, which views data in the form of a data cube. v A data cube allows data to be modeled and viewed in multiple dimensions. v Fact tables contain measures of interest (such as dollars sold) and keys to each of the related dimension tables. v Dimension tables provide the context of the measures such as item (item name, brand), product, location or time(day, week, month, quarter, year). 33
From Tables to Data Cubes ID Product Country Date Sales 1 TV US 1 Qtr 100 2 PC Canada 4 Qtr 500 3 CAR US 2 Qtr 30 4 PC UK 3 Qtr 200 5 CAR UK 1 Qtr 20 6 CAR UK 2 Qtr 15 7 TV Canada 4 Qtr 80 34
2 Qtr 3 Qtr 4 Qtr od TV PC CAR sum 1 Qtr Date sum Total annual sales of TV in U. S. A. Pr U. S. A Canada U. K. sum 35 Country uc t From Tables to Data Cubes
Cube: A Lattice of Cuboids all time, item 0 -D cuboid item time, location item, location time, supplier time, item, location supplier location, supplier item, supplier time, location, supplier time, item, supplier 1 -D cuboids 2 -D cuboids 3 -D cuboids item, location, supplier 4 -D cuboid time, item, location, supplier 36
Data Warehouse Schemas v Star Schema § A fact table in the middle connected to a set of dimension tables v 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 v Fact Constellations § Multiple fact tables sharing dimension tables, viewed as a collection of stars, therefore called galaxy schema or fact constellation 37
The Star Schema time item time_key day_of_the_week month quarter year Sales Fact Table time_key item_key branch_key branch_name branch_type location_key units_sold dollars_sold avg_sales Measures 38 item_key item_name brand type supplier_type location_key street city province_or_street country
The Star Schema: An Example 39
The Snowflake Schema time_key day_of_the_week month quarter year item_key item_name brand type supplier_key Sales Fact Table time_key item_key branch supplier_key supplier_type location_key branch_name branch_type supplier location_key street city_key units_sold dollars_sold city_key city province_or_street country avg_sales Measures 40
The Galaxy Schema time_key day_of_the_week month quarter year item Sales Fact Table time_key item_key item_name brand type supplier_type location_key branch_name branch_type units_sold dollars_sold avg_sales time_key item_key shipper_key from_location branch_key branch Shipping Fact Table location to_location_key street city province_or_street country dollars_cost Measures 41 units_shipped shipper_key shipper_name location_key shipper_type
Concept Hierarchy Location all Europe region country city office Germany Frankfurt . . Spain North_America Canada Vancouver. . . L. Chan . . . 42 . . . Toronto M. Wind
Set-Grouping Hierarchy [$0 - $1000] inexpensive moderate expensive [$0 - $150] 43
View of Hierarchies 44
Bitmap Index v Index on a particular column. v Each value in the column corresponds to a bit vector. v The length of the bit vector: # of unique records. v Not suitable for high cardinality domains Base Table Index on Region 45 Index on Type
OLAP v Online Analytical Processing v Fast Analysis of Shared Multidimensional Information (FASMI) v Slice and Dice: § Project and Select v Roll up (drill-up): summarize data § By climbing up hierarchy or by dimension reduction v Drill down (roll down): reverse of roll-up § From higher level summary to lower level summary or detailed data, or introducing new dimensions v Pivot (rotate): § Reorient the cube 46
Browsing a Data Cube 47
Slicing and dicing The Telecomm Slice Product Household Telecomm Video Audio s n o i g e R Europe Far East India Retail Direct Sales Channel Special 48
Roll-Up & Drill-Down v Sales Channel v Region v Country v State v Location Address v Sales Representative Drill-Down Roll Up Higher Level of Aggregation Low-level Details 49
50
Pivot NY LA SF te a D Juice Cola Milk Cream 47 30 12 Region 10 Product 3/1 3/2 3/3 3/4 51
OLAP Server Architectures v Relational OLAP (ROLAP) § Use relational DBMS to store and manage warehouse data. § ROLAP tools access the data in a relational database and generate SQL queries to calculate information at the appropriate level as required. § Greater scalability v Multidimensional OLAP (MOLAP) § Fast query performance due to optimized storage and indexing § Automated computation of higher level aggregates of the data § Very compact for low dimension data sets. § Array model provides natural indexing v Hybrid OLAP (HOLAP) § User flexibility § Low level: relational § High-level: array 52
Warehouse Products v Computer Associates -- CA-Ingres v Hewlett-Packard -- Allbase/SQL v Informix -- Informix, Informix XPS v Microsoft -- SQL Server v Oracle -- Oracle 7, Oracle Parallel Server v Red Brick -- Red Brick Warehouse v SAS Institute -- SAS v Software AG -- ADABAS v Sybase -- SQL Server, IQ, MPP 53
Data Warehouse Vendors 54
Data Warehouse Vendors 55
Review v What is a data warehouse? v What is data warehousing? v What is the difference between OLTP and data warehousing? v What does ETL stand for? v What is the meaning of Metadata? v What is the star schema? v What is the snowflake schema? v What is an OLAP cube? v What are the most common OLAP operations? 56
Next Week’s Class Talk v Volunteers are required for next week’s class talk. v Topic: Business Intelligence v Length: 20 minutes plus question time v Suggested Points of Interest § Aim & Scope • Techniques involved § Market • Vendors & Products § Typical applications • Supermarkets, Airlines, Financial Institutes … § Prospect of employment • Major BI companies § The future of BI • Development trends 57
Project Option--- Data Warehousing v Aim § To gain hand-on experiences on data warehousing. § To get familiar with popular data warehousing software. § To build up teamwork and interpersonal skills. v Deliverables § Reports § Oral Presentation or Poster v Due § Reports must be submitted before Week 14. § Oral presentations and posters are scheduled on Week 15. v Software § Power. OLAP § Instant. OLAP § Pentaho 58
- Slides: 58