SQL/OLAP Sang-Won Lee Let’s e-Wha! URL: Jul. 12th, 2001 SQL/OLAP

Slides:



Advertisements
Similar presentations
OLAP Tuning. Outline OLAP 101 – Data warehouse architecture – ROLAP, MOLAP and HOLAP Data Cube – Star Schema and operations – The CUBE operator – Tuning.
Advertisements

Outline What is a data warehouse? A multi-dimensional data model Data warehouse architecture Data warehouse implementation Further development of data.
5.1Database System Concepts - 6 th Edition Chapter 5: Advanced SQL Advanced Aggregation Features OLAP.
Data Warehousing CPS216 Notes 13 Shivnath Babu. 2 Warehousing l Growing industry: $8 billion way back in 1998 l Range from desktop to huge: u Walmart:
Introduction to Data Warehousing CPS Notes 6.
Set operators (UNION, UNION ALL, MINUS, INTERSECT) [SQL]
Chapter 11 Group Functions
OLAP Services Business Intelligence Solutions. Agenda Definition of OLAP Types of OLAP Definition of Cube Definition of DMR Differences between Cube and.
Data Warehousing - 2 ISYS 650. Data Warehouse Design - Star Schema - Dimension tables – contain descriptions about the subjects of the business such as.
OLAP. Overview Traditional database systems are tuned to many, small, simple queries. Some new applications use fewer, more time-consuming, analytic queries.
Data Cube and OLAP Server
Advanced Querying OLAP Part 2. Context OLAP systems for supporting decision making. Components: –Dimensions with hierarchies, –Measures, –Aggregation.
COMP 578 Data Warehousing And OLAP Technology Keith C.C. Chan Department of Computing The Hong Kong Polytechnic University.
1 Lecture 10: More OLAP - Dimensional modeling
Lab3 CPIT 440 Data Mining and Warehouse.
Data Warehousing. On-Line Analytical Processing (OLAP) Tools The use of a set of graphical tools that provides users with multidimensional views of their.
CSE6011 Warehouse Models & Operators  Data Models  relations  stars & snowflakes  cubes  Operators  slice & dice  roll-up, drill down  pivoting.
Online Analytical Processing (OLAP) Hweichao Lu CS157B-02 Spring 2007.
Data Cube: A Relational Aggregation Operator Generalizing Group-By, Cross-Tab, and Sub-Totals Presenter : Parminder Jeet Kaur Discussion Lead : Kailang.
Enhancements to the GROUP BY Clause Fresher Learning Program January, 2012.
Database Programming Sections 5– GROUP BY, HAVING clauses, Rollup & Cube Operations, Grouping Set, Set Operations 11/2/10.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Decision Support Chapter 23.
IST722 Data Warehousing Business Intelligence Development with SQL Server Analysis Services and Excel 2013 Michael A. Fudge, Jr.
Multi-Dimensional Databases & Online Analytical Processing This presentation uses some materials from: “ An Introduction to Multidimensional Database Technology,
Solving Business Problems In OLAP Services Using MDX – Part I Amir Netz – Dev Manager & Architect Ariel Netz – Program Manager SQL Server OLAP Services.
Ahsan Abdullah 1 Data Warehousing Lecture-11 Multidimensional OLAP (MOLAP) Virtual University of Pakistan Ahsan Abdullah Assoc. Prof. & Head Center for.
1 Cube Computation and Indexes for Data Warehouses CPS Notes 7.
OnLine Analytical Processing (OLAP)
DIMENSIONAL MODELLING. Overview Clearly understand how the requirements definition determines data design Introduce dimensional modeling and contrast.
OLAP & DSS SUPPORT IN DATA WAREHOUSE By - Pooja Sinha Kaushalya Bakde.
Data Warehousing.
Roadmap 1.What is the data warehouse, data mart 2.Multi-dimensional data modeling 3.Data warehouse design – schemas, indices 4.The Data Cube operator –
BI Terminologies.
ISO/IEC JTC1 SC32 1SQL/OLAP Sang-Won Lee Let’s e-Wha! URL: Jul. 12th,
1 On-Line Analytic Processing Warehousing Data Cubes.
Data Warehousing Multidimensional Analysis
Sales Dim Date Dim Customers Dim Products Dim Categories Dim Geography The data warehouse is a simple and standard one, after all we.
What is OLAP?.
Data Warehousing.
 After completing this lesson, you should be able to do the following: ◦ Use the ROLLUP operation to produce subtotal values ◦ Use the CUBE operation.
05 | SET Operators, Windows Functions, and Grouping Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Data Warehousing and Decision Support.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Data Warehousing and Decision Support Chapter 25.
Introduction to OLAP and Data Warehouse Assoc. Professor Bela Stantic September 2014 Database Systems.
Pindaro Demertzoglou Data Resource Management – MGMT 4170 Lally School of Management Rensselaer Polytechnic Institute.
Or How I Learned to Love the Cube…. Alexander P. Nykolaiszyn BLOG:
Data Warehousing and OLAP Outline u Models & operations u Implementing a warehouse u Future directions.
CSE6011 Implementing a Warehouse  Monitoring: Sending data from sources  Integrating: Loading, cleansing,...  Processing: Query processing, indexing,...
Data Analysis Decision Support Systems Data Analysis and OLAP Data Warehousing.
Data Analysis and OLAP Dr. Ms. Pratibha S. Yalagi Topic Title
Lecturer : Dr. Pavle Mogin
Data Warehousing CIS 4301 Lecture Notes 4/20/2006.
On-Line Analytic Processing
Efficient Methods for Data Cube Computation
OLAP – On Line Analytical Processing
Three tier Architecture of Data Warehousing
Chapter 5: Advanced SQL Database System concepts,6th Ed.
DATA CUBE Advanced Databases 584.
On-Line Analytical Processing (OLAP)
Data warehouse Design Using Oracle
Enhance BI Applications and Simplify Development
Oracle8i Analytical SQL Features
Data Warehousing and OLAP
DATA CUBES E0 261 Jayant Haritsa Computer Science and Automation
Online analytical processing (OLAP) is a category of software technology that enables analysts, managers, and executives to gain insight into data through.
Slides based on those originally by : Parminder Jeet Kaur
Pivoting and Grouping Sets
Data Warehousing.
Presentation transcript:

SQL/OLAP Sang-Won Lee Let’s e-Wha! Email: swlee@ewha.ac.kr URL: http://home.ewha.ac.kr/~swlee Jul. 12th, 2001 SQL/OLAP ISO/IEC JTC1 SC32

Contents Introduction to OLAP and SQL Issues Current OLAP Solutions SQL/OLAP Future OLAP Trends SQL/OLAP ISO/IEC JTC1 SC32

OLAP On-Line Analytical Processing E.F. Codd coined the term “OLAP”([1]) Multi-dimensional data model vs. On-Line Transaction Processing vs. Data warehouse SQL/OLAP ISO/IEC JTC1 SC32

Multi-dimensional Data Model Sales(prod-id,store-id,time-id,qty,amt) Dimension: Product, Store, Time Hierarchy: Product -> Category -> Industry Store->City -> State -> Country Date -> Month -> Quarter -> Year SQL/OLAP ISO/IEC JTC1 SC32

Multi-dimensional Data Model(2) Operations roll-up/drill-down slice/dice pivot ranking comparisons drill-across etc. Example for each state show me top 10 products based on total sales what is the percentage growth of Jan-99 total sales over total Jan-98? for each product show me the quantity shipped and sold SQL/OLAP ISO/IEC JTC1 SC32

OLAP Operations Many business operations was hard or impossible to express in SQL multiple aggregations comparisons(with aggregation) reporting features Be prepared for serious performance penalty Client and middle-ware tools provide the necessary functionality OLAP server: ROLAP vs. MOLAP SQL/OLAP ISO/IEC JTC1 SC32

Multiple Aggregations Create a 2-dimensional spreadsheets that shows sum of sales by maker as well as model of car Each subtotal requires a separate aggregate query SELECT color, make, sum(amt) FROM sales GROUP BY color, make union SELECT color, sum(amt) GROUP BY color SELECT make, sum(amt) GROUP BY make SELECT sum(amt) RED WHITE BLUE Chevy Ford By Make By Color Sum Cross Tab SQL/OLAP ISO/IEC JTC1 SC32

Comparisons Examples: last year’s sales vs. this year’s sales for each product requires a self-join VIEW: create or replace view v_sales as select prod-id, year, sum(qty) as sale_sum from sales group by prod-id, year; QUERY: select cur.year cur_year, cur.sale_cur_sales, last.sum last_sales from v_sales curr, v_sales last where curr.year=(last.year+1) SQL/OLAP ISO/IEC JTC1 SC32

The Data CUBE Relational Operator Generalizes Group By and Aggregates Sum Aggregate RED WHITE BLUE By Color Sum Group By (with total) RED WHITE BLUE Chevy Ford By Make By Color Sum Cross Tab The Data Cube and The Sub-Space Aggregates CHEVY FORD 1990 1991 1992 1993 By Year By Make By Make & Year RED WHITE BLUE By Color & Year By Make & Color Sum By Color source:[6] SQL/OLAP ISO/IEC JTC1 SC32

Getting Sub-totals: ROLLUP Operation SELECT year, brand, SUM(qty) FROM sales GROUP BY ROLLUP (year, brand); YEAR BRAND SUM(qty) 1996 Ford 250 1996 Honda 300 1996 Toyota 450 1997 Ford 300 … 1996 1000 ROLLUP Operator The ROLLUP operator can be used obtain sub-totals in a query. ROLLUP grouping is an extension to the GROUP BY clause in a query that produces a sub-totals in addition to the “regular” grouped rows. The sub-totals are rows that contain further aggregates whose values are derived by applying the same set functions that were used to obtain the grouped rows. In the example, the use of the ROLLUP operator produces the following rows in addition to the sum of AMOUNT for each YEAR-BRAND pair: Sum of QTY for each year Grand total of QTY for all the years If there are 2 years and 3 products as shown in the example, a GROUP BY operation without ROLLUP would produce at most 6 rows (m*n), while the same operation using ROLLUP could result in 9 rows (m*(n+1)+1). 1997 1200 2200 SQL/OLAP ISO/IEC JTC1 SC32

Getting Cross-tabs: CUBE Operation SELECT year, brand, SUM(amount) FROM sales GROUP BY CUBE (year, brand); YEAR BRAND SUM(AMOUNT) 1996 Ford 250 ... 1996 Toyota 450 1997 Ford 300 ... 1997 1200 2200 Ford 550 Honda 650 Toyota 1000 A CUBE grouping is an extension to the GROUP BY within a query that produces a result set that contains sub-totals for every possible combinations of the columns or expressions in the GROUP BY clause. The aggregation of those rows are known as n-dimensional cross-tabulation, and produces cubes as discussed earlier. In the example shown the CUBE operator would produce productwise sub-totals in addition to all the aggregates produced by the ROLLUP operation. Distinguishing NULLs: GROUPING Function In the result of a ROLLUP or CUBE operation, a NULL value is used to represents the “ALL” value - that is, in the total for year-1, a NULL is shown against the product column. This presents a problem where a user cannot differentiate between an actual NULL and a null representing “ALL”. A new function GROUPING is used to distinguish between the two types of NULLs. Grouping is a set function that returns the value 1 if the value in the column in the row is a NULL that represents the set of all values resulting from a ROLLUP or CUBE operation. Where the NULL represents traditional NULL, the function returns the value 0. SQL/OLAP ISO/IEC JTC1 SC32

Flexible Grouping: GROUPING_SETS Operator SELECT year, brand, color, SUM(qty) FROM sales GROUP BY GROUPING_SETS ((year, brand), (brand,color),()); YEAR BRAND COLOR SUM(QTY) 1996 Ford 250 1996 Honda 300 1996 Toyota 450 1997 Ford 300 1997 Honda 350 1997 Toyota 550 Ford Blue 400 Ford Red 150 Honda Blue 650 Toyota Red 700 Toyota White 300 2200 Year, Brand Brand, Color The GROUPING_SETS operator can be used to group multiple unrelated groupings without the need to use set operations. Grand total SQL/OLAP ISO/IEC JTC1 SC32

LAG Operator SQL> SELECT timekey, sales 2 LAG(sales, 12) OVER 3 (ORDER BY timekey) AS sales_last_year, 4 (sales - sales_last_year) AS sales_change 5 FROM sales; TIMEKEY SALES SALES_LAST_YEAR SALES_CHANGE 98-1 1100 - - ….. … … ... 99-1 1200 1100 100 99-2 1500 1450 50 99-3 1700 1350 250 99-4 1600 1700 -100 99-5 1800 1600 200 99-6 1500 1450 50 99-7 1300 1250 50 99-8 1400 1200 200 SQL/OLAP ISO/IEC JTC1 SC32

MOVING Average SELECT time-id, avg(sum(qty)) over (order by time-id RANGE INTERVAL ‘2’ DAY PRECEDING ) as mvg_avg_sales from sales group by time_id ; SQL/OLAP ISO/IEC JTC1 SC32