VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Pivoting and SQL:1999.

Slides:



Advertisements
Similar presentations
Data Warehousing and Decision Support, part 2
Advertisements

Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
5.1Database System Concepts - 6 th Edition Chapter 5: Advanced SQL Advanced Aggregation Features OLAP.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Jennifer Widom On-Line Analytical Processing (OLAP) Introduction.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 391 Database Systems I Data Warehousing.
ICS 421 Spring 2010 Data Warehousing 2 Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 3/30/20101Lipyeow.
OLAP and Data Mining Chapter 17.
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.
Chap8: Trends in DBMS 8.1 Database support for Field Entities 8.2 Content-based retrieval 8.3 Introduction to spatial data warehouses 8.4 Summary.
COMP 578 Data Warehousing And OLAP Technology Keith C.C. Chan Department of Computing The Hong Kong Polytechnic University.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Data Warehousing and Decision Support Chapter 25, Part A.
1 Lecture 10: More OLAP - Dimensional modeling
CSE6011 Warehouse Models & Operators  Data Models  relations  stars & snowflakes  cubes  Operators  slice & dice  roll-up, drill down  pivoting.
Ch3 Data Warehouse part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2009.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Write Lecturer.
Data Cube: A Relational Aggregation Operator Generalizing Group-By, Cross-Tab, and Sub-Totals Presenter : Parminder Jeet Kaur Discussion Lead : Kailang.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Decision Support Chapter 23.
 Data warehouses  Decision support  The multidimensional model  OLAP queries.
Ahsan Abdullah 1 Data Warehousing Lecture-12 Relational OLAP (ROLAP) Virtual University of Pakistan Ahsan Abdullah Assoc. Prof. & Head Center for Agro-Informatics.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 1 Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XQuery.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XQuery.
1 CUBE: A Relational Aggregate Operator Generalizing Group By By Ata İsmet Özçelik.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Storage Techniques.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation eXist Update Lecturer.
20.5 Data Cubes Instructor : Dr. T.Y. Lin Chandrika Satyavolu 222.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Aggregation.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Query Data Model Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Identity Constraints.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XML.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Decision Support Chapter 23.
Data Warehouse & OLAP Kuliah 1 Introduction Slide banyak mengambil dari acuan- acuan yang dipakai.
Data Warehousing.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Exam and Lecture Overview.
©Silberschatz, Korth and Sudarshan18.1Database System Concepts - 5 th Edition, Aug 26, 2005 Extended Aggregation in SQL:1999 The cube operation computes.
BI Terminologies.
13 1 Chapter 13 The Data Warehouse Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
1 On-Line Analytic Processing Warehousing Data Cubes.
OLAP & Data Warehousing. R. Ramakrishnan and J. Gehrke1 Decision Support Chapter 23.
Online Analytical Processing (OLAP) An Overview Kian Win Ong, Nicola Onose Mar 3 rd 2006.
13 1 Chapter 13 The Data Warehouse Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Data Warehousing and Decision Support.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Advanced Database Design.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Data Warehousing and Decision Support Chapter 25.
1 Database Systems, 8 th Edition Star Schema Data modeling technique –Maps multidimensional decision support data into relational database Creates.
Introduction to OLAP and Data Warehouse Assoc. Professor Bela Stantic September 2014 Database Systems.
Data Warehouses and OLAP 1.  Review Questions ◦ Question 1: OLAP ◦ Question 2: Data Warehouses ◦ Question 3: Various Terms and Definitions ◦ Question.
Data Analysis Decision Support Systems Data Analysis and OLAP Data Warehousing.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation OLAP Queries and SQL:1999.
Data Analysis and OLAP Dr. Ms. Pratibha S. Yalagi Topic Title
Query Optimization Heuristic Optimization
Lecturer : Dr. Pavle Mogin
OLAP Database Structures
Lecturer : Dr. Pavle Mogin
On-Line Analytic Processing
Efficient Methods for Data Cube Computation
7/4/2018.
7/5/2018.
Dimension Hierarchies
Chapter 5: Advanced SQL Database System concepts,6th Ed.
SQL: Structured Query Language DML- Queries Lecturer: Dr Pavle Mogin
DATA CUBE Advanced Databases 584.
On-Line Analytical Processing (OLAP)
Data warehouse Design Using Oracle
Chapter 4 Summary Query.
DATA CUBES E0 261 Jayant Haritsa Computer Science and Automation
Slides based on those originally by : Parminder Jeet Kaur
Presentation transcript:

VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Pivoting and SQL:1999 Lecturer : Dr. Pavle Mogin

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 1 Plan for Pivoting and SQL:1999 Inefficiency of implementing pivoting using SQL/92 New SQL commands: –CUBE –ROLLUP –Reading Ramakrishnan, Gehrke: “Database Management Systems”, Chapter 25, Sections 25.3, 25.4, and 25.6 Chaudhuri and Dayal : “An Overview of Datawarehousing and OLAP Technologies”

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 2 Summary of the Cross Tab Example SELECT City, Day, SUM(Amnt)… GROUP BY City, Day SELECT City … GROUP BY City; SELECT Day … GROUP BY Day; SELECT SUM(Amnt) FROM Sales {City, Day} {City} {Day} { } Structures like that one are often called cube lattice

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 3 Inefficiency of Multiple SELECTs To express pivoting over n dimensions, one has to declare 2 n SELECT SQL/92 statements Much worse, query optimizer will treat each SELECT as a separate block and evaluate it from the scratch, performing many joins and aggregations in vane Namely, very often, each node down the lattice may be evaluated from its ancestor

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 4 Using Ancestors Let us denote by V1 the result of the query SELECT City, Day, SUM(Amnt) AS Sale FROM Sales s, Location l, Time t WHERE s.LocId = l.LocId AND s.TimId = t.TimId GROUP BY City, Day; Then SELECT City, ‘’, SUM(Amnt) FROM Sales s, Location l WHERE s.ShopId = l.ShopId GROUP BY City; may be rewritten as SELECT City, ‘’, SUM(Sale) FROM V1 GROUP BY City; and thus computing a costly join will be saved (and some aggregating, as well)

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 5 SQL:1999 Extensions to GROUP BY Pivoting can be expressed by a series of SQL statements of the roll-up type: SELECT SUM(Measure) FROM NATURAL JOIN WHERE GROUP BY Recognizing the high level of similarities between such frequently used statements and the need to compute them efficiently has lad to extending the GOUP BY clause by CUBE and ROLLUP constructs

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 6 SQL:1999 CUBE Extension The GROUP BY clause with CUBE keyword is equivalent to a collection of GROUP BY statements, with one GROUP BY statement for each subset of n dimensions The statement SELECT City, Month, SUM(Amnt) AS Sale FROM Sales s, Location l, Time t WHERE s.LocId = l.LocId AND s.TimId = t.TimId GROUP BY CUBE (City, Month); will produce the same result as four other SQL statements with all subsets of {City, Month} as grouping attributes

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 7 CUBE Given a fact table Sales(ProdId, LocId, TimeId, Amnt ) with Product, Location, and Time dimensions The SQL statement with the CUBE clause SELECT ProdType, City, Month, SUM(Amnt) FROM Slales s, Time t, Location l, Product p WHERE s.TimeId = t.TimeId AND s.LocId = l.LocId AND s.ProdId = p.ProdId GROUP BY CUBE (ProdType, City, Month); will rollup the Amnt attribute on all eight subsets of the set {ProdType, City, Month} The CUBE clause will calculate the SUM of Amnt for each subset of the set {ProdType, City, Month}

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 8 CUBE Graph ProdType, City, Month ProdType, City ProdType, MonthCity, Month ProdTypeCity Month { } SELECT ProdType, City, Month, SUM(Amnt) FROM Sales NATURAL JOIN Product NATURAL JOIN Location NATURAL JOIN Time GROUP BY ProdType, City, Month;  SELECT SUM(Amnt) FROM Sales;  a  b: b may be inferred from a

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 9 Question for you Given a star schema with four dimensions How many SELECT – SUM – GROUP BY statements will be replaced by a SELECT – SUM – GROUP BY CUBE statement?

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 10 SQL:1999 ROLLUP Standard SQL:1999 also offers a variant of GROUP BY CUBE clause to compute subsets of a cross- tabulation The SQL statement SELECT City, Day, SUM(Amnt) AS Sale FROM Sales s, Location l, Time t WHERE s.LocId = l.LocId AND s.TimId = t.TimId GROUP BY ROLLUP (City, Day); will compute SUM(Amnt) on {City, Day}, {City}, and {} Note, ROLLUP computes aggregates for the subsets produced by successive omitting the last component in the GROUP BY attribute list

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 11 Justification of the CUBE and ROLLUP The CUBE and ROLLUP clauses are introduced to provide for efficient computation of cross tabulation using cube cells of finer granularity to produce cube cells of coarser granularity If the GROUP BY list contains n attributes from different dimension tables, this way will be at least 2 n – 1 joins saved, and aggregate functions will be computed using intermediate results, instead of starting each time from scratch

SWEN 432 Advanced Database Design and Implementation_ OLAP Queries 12 Summary Pivoting is a basic OLAP operation Traditionally, pivoting is done by issuing a sequence of SELECT with aggregate …GROUP BY…; SQL statements (SQL roll-up statements) To enhance computing of pivoting tables, SQL:1999 has introduced: –CUBE and –ROLLUP These two new clauses compute courser rollup aggregates using finer grained aggregates and thus save costly joins and lower computing costs of aggregates