CS848: Topics in Databases: Foundations of Query Optimization Topics covered Overview of DEMO  Capturing database schema in QL  Differential query optimization.

Slides:



Advertisements
Similar presentations
Physical Database Design and Tuning R&G - Chapter 20 Although the whole of this life were said to be nothing but a dream and the physical world nothing.
Advertisements

Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
CS848: Topics in Databases: Foundations of Query Optimization Topics covered  Introduction to description logic: Single column QL  The ALC family of.
Query Optimization CS634 Lecture 12, Mar 12, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
CS 540 Database Management Systems
Evaluation of Relational Operators CS634 Lecture 11, Mar Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Database Management Systems, R. Ramakrishnan and Johannes Gehrke1 Evaluation of Relational Operations: Other Techniques Chapter 12, Part B.
Query Evaluation. An SQL query and its RA equiv. Employees (sin INT, ename VARCHAR(20), rating INT, age REAL) Maintenances (sin INT, planeId INT, day.
SPRING 2004CENG 3521 Query Evaluation Chapters 12, 14.
Query processing and optimization. Advanced DatabasesQuery processing and optimization2 Definitions Query processing –translation of query into low-level.
Spring 2003 ECE569 Lecture 06.1 ECE 569 Database System Engineering Spring 2003 Topic VIII: Query Execution and optimization Yanyong Zhang
Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Chapter 3 An Introduction to Relational Databases.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
Physical Database Monitoring and Tuning the Operational System.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts - 6 th Edition SQL Schema Changes and table updates instructor teaches.
Chapter 17 Methodology – Physical Database Design for Relational Databases Transparencies © Pearson Education Limited 1995, 2005.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Query Optimization, part 2 CS634 Lecture 13, Mar Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Chapter 3 An Introduction to Relational Databases.
CS848: Topics in Databases: Foundations of Query Optimization Topics Covered  Databases  QL  Query containment  More on QL.
Lecture 9 Methodology – Physical Database Design for Relational Databases.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Chapter 16 Methodology – Physical Database Design for Relational Databases.
ABC Insurance Co. Paul Barry Steve Randolph Jing Zhou CSC8490 Database Systems & File Management Dr. Goelman Villanova University August 2, 2004.
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
©Silberschatz, Korth and Sudarshan13.1Database System Concepts Chapter 13: Query Processing Overview Measures of Query Cost Selection Operation Sorting.
Chapter 13 Query Processing Melissa Jamili CS 157B November 11, 2004.
Query Processing. Steps in Query Processing Validate and translate the query –Good syntax. –All referenced relations exist. –Translate the SQL to relational.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
10/10/2012ISC239 Isabelle Bichindaritz1 Physical Database Design.
Storage and Indexing1 Overview of Storage and Indexing.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8.
Methodology – Physical Database Design for Relational Databases.
CPSC 203 Introduction to Computers Lab 60 By Jie Gao.
3/18: Microsoft Access Refresher: What is a relational database? Why use a database? Sample database in MS access. –Fields, records, attributes. –Tables,
CS848: Topics in Databases: Information Integration Topics covered  Databases  QL  Query containment  An evaluation of QL.
CS4432: Database Systems II Query Processing- Part 2.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
ABAP Dictionary Introduction Tables in the ABAP Dictionary Performance in Table Access Consistency through Input Check Dependencies of ABAP Dictionary.
Relational Operator Evaluation. Overview Application Programmer (e.g., business analyst, Data architect) Sophisticated Application Programmer (e.g.,
CPSC 404, Laks V.S. Lakshmanan1 Overview of Query Evaluation Chapter 12 Ramakrishnan & Gehrke (Sections )
CPSC 203 Introduction to Computers Lab 21 By Jie Gao.
1 Overview of Query Evaluation Chapter Outline  Query Optimization Overview  Algorithm for Relational Operations.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. A database is a collection of information organized to provide efficient retrieval. The collected information.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة.
Chapter 3 An Introduction to Relational Databases.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #15: Physical DB Design Instructor: Chen Li.
Storage and File Organization
Module 11: File Structure
Indexes By Adrienne Watt.
CS522 Advanced database Systems
Storage and Indexes Chapter 8 & 9
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Chapter 12: Query Processing
Relational Algebra Chapter 4, Part A
Translation of ER-diagram into Relational Schema
Tree-Structured Indexes
Relational Algebra Chapter 4, Sections 4.1 – 4.2
CMPT 354: Database System I
Lecture 2- Query Processing (continued)
Advance Database Systems
Overview of Query Evaluation
Evaluation of Relational Operations: Other Techniques
Topics covered (class assignment)
Presentation transcript:

CS848: Topics in Databases: Foundations of Query Optimization Topics covered Overview of DEMO  Capturing database schema in QL  Differential query optimization  Dialect DLA  Capturing database schema in DLA

CS848: Topics in Databases: Foundations of Query Optimization Capturing database schema in QL  Another view on views  Another view on physical design

CS848: Topics in Databases: Foundations of Query Optimization Tables: current practice  Tables that are base  Tables that are views (defined by queries on base tables) create table EMP ( attribute name on STR; attribute age on INT; attribute loc on STR; primary key (name); ) create view WATEMP ( select name, age from EMP where loc = ‘Waterloo’; ) create view TOREMP ( select name from EMP where loc = ‘Toronto’; )

CS848: Topics in Databases: Foundations of Query Optimization Tables: an alternative  Tables  Constraints (query containment dependencies) ( select name, age from EMP where loc = ‘Waterloo’ ) ´ ( select name, age from WATEMP ) ( select name from EMP where loc = ‘Toronto’ ) ´ ( select name from TOREMP ) create table EMP ( attribute name on STR; attribute age on INT; attribute loc on STR; primary key (name); updatable; ) create table WATEMP ( attribute name on STR; attribute age on INT; ) create table TOREMP ( attribute name on STR; )

CS848: Topics in Databases: Foundations of Query Optimization Table: an alternative (cont’d)  Easy to do much more! ( select name, age from EMP where loc = ‘Waterloo’ ) ´ ( select name, age from WATEMP ) ( select name from EMP where loc = ‘Toronto’ ) ´ ( select name from TOREMP ) ( select name from EMP ) ´ ( select name from WATEMP ) union all ( select name from TOREMP ) create table EMP ( attribute name on STR; attribute age on INT; attribute loc on STR; primary key (name); updatable; ) create table WATEMP ( attribute name on STR; attribute age on INT; ) create table TOREMP ( attribute name on STR; )

CS848: Topics in Databases: Foundations of Query Optimization Physical design: current practice  Records and fields (implicit)  Clustered indices on base tables (a default file created)  Secondary indices on base tables  Materialized views (a default file created)  Secondary indices on materialized views  Etc.  External engines (collections of tables, views and the above) create index on EMP (loc asc, age desc) alter view WATEMP ( materialized; ) create index on WATEMP (name asc)

CS848: Topics in Databases: Foundations of Query Optimization Physical design: an alternative  Explicit named record identifiers and stored attributes  Iterator signatures  Secondary indices are also base relations alter table EMP ( record identifier emp; stored (name, age, loc); iterator; ) create table EMPX ( attribute loc on STR; attribute age on INT; attribute eref on RID; stored (loc, age, eref); iterator (loc asc, age desc); ) ( select loc, age, emp from EMP ) ´ ( select loc, age, eref from EMPX )

CS848: Topics in Databases: Foundations of Query Optimization Physical design: an alternative (cont’d) alter table WATEMP ( record identifier emp; stored (name, age); iterator; ) create table WATEMPX ( attribute name on STR; attribute eref on RID; stored (name, eref); iterator (name asc); ( select name, emp from WATEMP ) ´ ( select name, eref from WATEMPX )

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization select name, age from EMP where loc = ‘Waterloo’ and name = :p (based on simple hill climbing) 1.Expand conjunctive subquery using constraints. 2.Initialize subplan. 3.Select next iterator or disjunction from query for subplan; fail if none available. 4.If disjunction selected, recursively apply steps 1 to 5 on each disjunct; fail if any recursive application fails. 5.If expand of subplan contains subquery, return subplan; otherwise repeat from 3. select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) 1.Expand conjunctive subquery using constraints. select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age ( select name, age from EMP where loc = ‘Waterloo’ ) ´ ( select name, age from WATEMP ) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) 1.Expand conjunctive subquery using constraints. select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age ( select name, emp from WATEMP ) ´ ( select name, eref from WATEMPX ) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref 2.Initialize subplan. select from PV as :p (plan) (query parameter)

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref 3.Select next iterator or disjunction from query for subplan; fail if none available. select from PV as :p (plan)

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name where name = :p (plan) (nested loops; string copy) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref 3.Select next iterator or disjunction from query for subplan; fail if none available.

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name where name = :p (plan) 5.If expand of subplan contains subquery, return subplan; otherwise repeat from 3. (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name where name = :p (expanded plan) 5.If expand of subplan contains subquery, return subplan; otherwise repeat from 3. (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name where name = :p (plan) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref 3.Select next iterator or disjunction from query for subplan; fail if none available.

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name, WATEMPX as x where name = :p and x.name = name (plan) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref 3.Select next iterator or disjunction from query for subplan; fail if none available. (nested loops; index scan)

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name, WATEMPX as x where name = :p and x.name = name (plan) 5.If expand of subplan contains subquery, return subplan; otherwise repeat from 3. (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name, age from PV as :p, (STR u QV) as name, WATEMPX as x, WATEMP as w, INT as age, EMP as e where name = :p and x.name = name and w.name = x.name and w.emp = x.eref and e.name = w.name and e.age = w.age and e.age = age and e.loc = ‘Waterloo’ (expanded plan) 5.If expand of subplan contains subquery, return subplan; otherwise repeat from 3. (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name, WATEMPX as x where name = :p and x.name = name (plan) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref 3.Select next iterator or disjunction from query for subplan; fail if none available.

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name, WATEMPX as x, WATEMP as w where name = :p and x.name = name and w.emp = x.eref (plan) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref 3.Select next iterator or disjunction from query for subplan; fail if none available. (nested loops; pointer navigation)

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name, WATEMPX as x, WATEMP as w where name = :p and x.name = name and w.emp = x.eref (plan) 5.If expand of subplan contains subquery, return subplan; otherwise repeat from 3. (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name, age from PV as :p, (STR u QV) as name, WATEMPX as x, WATEMP as w, INT as age, EMP as e where name = :p and x.name = name and w.emp = x.eref and w.name = x.name and e.name = w.name and e.age = w.age and e.age = age and e.loc = ‘Waterloo’ (expanded plan) 5.If expand of subplan contains subquery, return subplan; otherwise repeat from 3. (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name from PV as :p, (STR u QV) as name, WATEMPX as x, WATEMP as w where name = :p and x.name = name and w.emp = x.eref (plan) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref 3.Select next iterator or disjunction from query for subplan; fail if none available.

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name, age from PV as :p, (STR u QV) as name, WATEMPX as x, WATEMP as w, (INT u QV) as age where name = :p and x.name = name and w.emp = x.eref and age = w.age (plan) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age, WATEMP as w, WATEMPX as x where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age and e.name = w.name and e.age = w.age and w.name = x.name and w.emp = x.eref 3.Select next iterator or disjunction from query for subplan; fail if none available. (nested loops; field extraction)

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name, age from PV as :p, (STR u QV) as name, WATEMPX as x, WATEMP as w, (INT u QV) as age where name = :p and x.name = name and w.emp = x.eref and age = w.age (plan) (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age 5.If expand of subplan contains subquery, return subplan; otherwise repeat from 3.

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name, age from PV as :p, (STR u QV) as name, WATEMPX as x, WATEMP as w, (INT u QV) as age, EMP as e where name = :p and x.name = name and w.emp = x.eref and age = w.age and w.name = x.name and e.name = w.name and e.age = w.age and e.age = age and e.loc = ‘Waterloo’ (expanded plan) 5.If expand of subplan contains subquery, return subplan; otherwise repeat from 3. (expanded query) select name, age from EMP as e, PV as :p, (STR u QV) as name, (INT u QV) as age where e.loc = ‘Waterloo’ and e.name = :p and e.name = name and e.age = age

CS848: Topics in Databases: Foundations of Query Optimization Differential query optimization (cont’d) select name, age from PV as :p, // input parameter (STR u QV) as name, // string copy WATEMPX as x, // index scan WATEMP as w, // pointer navigation (INT u QV) as age // field extraction where name = :p and x.name = name and w.emp = x.eref and age = x.age (final plan)

CS848: Topics in Databases: Foundations of Query Optimization Dialect DLA D ::= (universal concept) | >  (primitive concept) |C (C) I (bottom concept) | ? ; (negation) | : D  – (D) I (intersection) |D 1 u D 2 (D 1 ) I Å (D 2 ) I (union) |D 1 t D 2 (D 1 ) I [ (D 2 ) I (attribute value restriction) | 8 A.D {e : (A) I (e) 2 (D) I } (quantified attribute inverse) |( > n A) {e 1 : |{e 2 : (A) I (e 2 ) = e 1 }| ¸ n} (quantified attribute inverse) |( 6 n A) {e 1 : n ¸ |{e 2 : (A) I (e 2 ) = e 1 }|} (path agreement) |Pf 1 = Pf 2 {e : (Pf 1 ) I (e) = (Pf 2 ) I (e)} (path disagreement) |Pf 1  Pf 2 {e : (Pf 1 ) I (e)  (Pf 2 ) I (e)} (path functional dependency) |C : L 1 ! L 2 (next slide) (an individual) | ¤ 2  Pf ::=id | A. Pf L ::=id | A | L. L | L, L | { L }

CS848: Topics in Databases: Foundations of Query Optimization Semantics of PFDs (C : L 1 ! L 2 ) I ´ f e 1 : 8 e 2 2 (C) I : Æ (Pf ) I (e 1 ) = (Pf ) I (e 2 ) ! Æ (Pf ) I (e 1 ) = (Pf ) I (e 2 ) g Pf 2 L (L 1 ) Pf 2 L (L 2 ) where L (id) ´ {id} L (A) ´ {A. id} L (L 1. L 2 ) ´ {Pf 1 ± Pf 2 : Pf 1 2 L (L 1 ) Æ Pf 2 2 L (L 2 )} L (L 1, L 2 ) ´ L (L 1 ) [ L (L 2 ) L ({L}) ´ L (L) where id ± Pf ´ Pf (A. Pf 1 ) ± Pf 2 ´ A. (Pf 1 ± Pf 2 )

CS848: Topics in Databases: Foundations of Query Optimization Sample partial database EMP emp (RID) name (STR) Waterloo Toronto Waterloo age (INT) Mary Ann Fred @ EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age

CS848: Topics in Databases: Foundations of Query Optimization DLA : primitive concepts EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age  STR

CS848: Topics in Databases: Foundations of Query Optimization DLA : primitive concepts (cont’d) EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age  STR  EMP

CS848: Topics in Databases: Foundations of Query Optimization DLA : attribute value restriction EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age  STR  EMP  8 loc.STR

CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : path functional dependencies EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age  STR  EMP  8 loc.STR  EMP:{loc} ! {name}

CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : quantified attribute inverse EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age  STR  EMP  8 loc.STR  EMP:{loc} ! {name}  ( > 1 loc)

CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : path agreement EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age  STR  EMP  8 loc.STR  EMP:{loc} ! {name}  ( > 1 loc)  name = loc

CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : intersection EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age  STR  EMP  8 loc.STR  EMP:{loc} ! {name}  ( > 1 loc)  name = loc  RID u ( > 1 emp)

CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : negation EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age  STR  EMP  8 loc.STR  EMP:{loc} ! {name}  ( > 1 loc)  name = loc  RID u ( > 1 emp)  : ( > 1 emp)

CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age Models  EMP v 8 loc.STR

CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies (cont’d) EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age Models  EMP v 8 loc.STR  ( > 1 loc) v : INT

CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies (cont’d) EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age Models  EMP v 8 loc.STR  ( > 1 loc) v : INT  EMP v EMP:{Name} ! { id }

CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies (cont’d) EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age Does not model  EMP v STR Models  EMP v 8 loc.STR  ( > 1 loc) v : INT  EMP v EMP:{Name} ! { id }

CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies (cont’d) EMP STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age Does not model  EMP v STR  EMP v EMP:{Loc} ! {Name} Models  EMP v 8 loc.STR  ( > 1 loc) v : INT  EMP v EMP:{Name} ! { id }

CS848: Topics in Databases: Foundations of Query Optimization Capturing database schema in DLA (recall alternative view on views)  Tables  QL dependencies ( select name, age from EMP where loc = ‘Waterloo’ ) ´ ( select name, age from WATEMP ) ( select name from EMP where loc = ‘Toronto’ ) ´ ( select name from TOREMP ) ( select name from EMP ) ´ ( select name from WATEMP ) union all ( select name from TOREMP ) create table EMP ( attribute name on STR; attribute age on INT; attribute loc on STR; primary key (name); updatable; ) create table WATEMP ( attribute name on STR; attribute age on INT; ) create table TOREMP ( attribute name on STR; )

CS848: Topics in Databases: Foundations of Query Optimization DLA schema: capturing tables EMP v ( 8 name.STR ) u ( 8 age.INT ) u ( 8 loc.STR ) WATEMP v ( 8 name.STR ) u ( 8 age.INT ) TOREMP v 8 name.STR (signatures; typing) create table EMP ( attribute name on STR; attribute age on INT; attribute loc on STR; primary key (name); updatable; ) create table WATEMP ( attribute name on STR; attribute age on INT; ) create table TOREMP ( attribute name on STR; )

CS848: Topics in Databases: Foundations of Query Optimization DLA schema: capturing tables EMP v ( 8 name.STR ) u ( 8 age.INT ) u ( 8 loc.STR ) WATEMP v ( 8 name.STR ) u ( 8 age.INT ) TOREMP v 8 name.STR EMP v EMP:{name} ! { id } (primary keys) create table EMP ( attribute name on STR; attribute age on INT; attribute loc on STR; primary key (name); updatable; ) create table WATEMP ( attribute name on STR; attribute age on INT; ) create table TOREMP ( attribute name on STR; )

CS848: Topics in Databases: Foundations of Query Optimization DLA schema: capturing tables EMP v ( 8 name.STR ) u ( 8 age.INT ) u ( 8 loc.STR ) WATEMP v ( 8 name.STR ) u ( 8 age.INT ) TOREMP v 8 name.STR EMP v EMP:{name} ! { id } CLASS v OBJECT u : DOMAIN DOMAIN v OBJECT u : CLASS EMP v CLASS u UPDATABLE u : WATEMP u : TOREMP WATEMP v CLASS u : EMP u : TOREMP TOREMP v OBJECT u : EMP u : WATEMP INT v DOMAIN u : STR STR v DOMAIN u : INT (generalization hierarchies) create table EMP ( attribute name on STR; attribute age on INT; attribute loc on STR; primary key (name); updatable; ) create table WATEMP ( attribute name on STR; attribute age on INT; ) create table TOREMP ( attribute name on STR; )

CS848: Topics in Databases: Foundations of Query Optimization QL dependencies to DLA dependencies ( select name, age from EMP where loc = ‘Waterloo’ ) ´ ( select name, age from WATEMP ) ( select name from EMP where loc = ‘Toronto’ ) ´ ( select name from TOREMP ) ( select name from EMP ) ´ ( select name from WATEMP ) union all ( select name from TOREMP ) (class assignment)

CS848: Topics in Databases: Foundations of Query Optimization Physical design to DLA dependencies (homework assignment)

CS848: Topics in Databases: Foundations of Query Optimization Interfacing to a DLA theorem prover Observation: A partial database I encodes both a query Q( I ) in conjunctive QL and a concept description D( I ) that characterizes any tuple in the evaluation of Q( I ). Example normal form: select name, age, :p from(QV u IV) as name, (QV u IV) as age, (PV) as :p, (IV u EMP) as e, ( elim name, age, :p from(EV u WATERLOO) as c wherename = :p, name = e.name, age = e.age, e.loc = c, ( fromname = name, age = age, :p = :p )) select name, age from EMP where loc = ‘Waterloo’ and name = :p

CS848: Topics in Databases: Foundations of Query Optimization Query expansion and the simple chase Theorem: Let I 1 denote a partial database and I 2 the result of a simple chase of I 1 relative to terminology T. Then T ² Q( I 1 ) ´ Q( I 2 ).