Download presentation
Presentation is loading. Please wait.
Published byWillis Banks Modified over 9 years ago
1
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
2
CS848: Topics in Databases: Foundations of Query Optimization Capturing database schema in QL Another view on views Another view on physical design
3
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’; )
4
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; )
5
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; )
6
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)
7
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 )
8
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 )
9
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
10
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
11
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
12
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)
13
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)
14
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.
15
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
16
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
17
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.
18
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)
19
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
20
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
21
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.
22
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)
23
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
24
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
25
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.
26
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)
27
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.
28
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
29
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)
30
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 }
31
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 )
32
CS848: Topics in Databases: Foundations of Query Optimization Sample partial database EMP emp (RID) name (STR) Waterloo Toronto Waterloo age (INT) Mary Ann Fred loc (STR) @1 @2 @3 37 28 33 EMP RID @3 RID @2 RID @1 STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age
33
CS848: Topics in Databases: Foundations of Query Optimization DLA : primitive concepts EMP RID @3 RID @2 RID @1 STR Mary Waterloo STR STR Fred Toronto STRSTR Ann 28 INT 37 INT 33 INT ageemp nameloc empage loc name emp name age STR
34
CS848: Topics in Databases: Foundations of Query Optimization DLA : primitive concepts (cont’d) EMP RID @3 RID @2 RID @1 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
35
CS848: Topics in Databases: Foundations of Query Optimization DLA : attribute value restriction EMP RID @3 RID @2 RID @1 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
36
CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : path functional dependencies EMP RID @3 RID @2 RID @1 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}
37
CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : quantified attribute inverse EMP RID @3 RID @2 RID @1 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)
38
CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : path agreement EMP RID @3 RID @2 RID @1 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
39
CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : intersection EMP RID @3 RID @2 RID @1 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)
40
CS848: Topics in Databases: Foundations of Query Optimization EMP DLA : negation EMP RID @3 RID @2 RID @1 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)
41
CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies EMP RID @3 RID @2 RID @1 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
42
CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies (cont’d) EMP RID @3 RID @2 RID @1 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
43
CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies (cont’d) EMP RID @3 RID @2 RID @1 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 }
44
CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies (cont’d) EMP RID @3 RID @2 RID @1 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 }
45
CS848: Topics in Databases: Foundations of Query Optimization DLA : dependencies (cont’d) EMP RID @3 RID @2 RID @1 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 }
46
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; )
47
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; )
48
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; )
49
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; )
50
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)
51
CS848: Topics in Databases: Foundations of Query Optimization Physical design to DLA dependencies (homework assignment)
52
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
53
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 ).
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.