Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 9. Evaluation of Queries Query evaluation –. 2 9.1 Quantifier Elimination and Satisfiability Example: Logical Level: r   y 1,…y n  r’ Constraint.

Similar presentations


Presentation on theme: "1 9. Evaluation of Queries Query evaluation –. 2 9.1 Quantifier Elimination and Satisfiability Example: Logical Level: r   y 1,…y n  r’ Constraint."— Presentation transcript:

1 1 9. Evaluation of Queries Query evaluation –

2 2 9.1 Quantifier Elimination and Satisfiability Example: Logical Level: r   y 1,…y n  r’ Constraint level: S  eliminate x  S’ Infinite relation r(x, y 1,…y n ) equivalent to constraint relation S. Infinite relation r’(y 1,…y n ) equivalent to constraint relation S’. Quantifier elimination – S’ =  x S – S’ is equivalent to eliminating x from S Closed quantifier elimination – when S’ and S have the same type of constraints.

3 3 QE is closed for conjunctions of: Infinite domain equality and inequality Rational order Integer/rational gap-order, lower and upper bound Integer/rational half-addition, lower and upper bound Integer/rational gap-order, upper bound, and positive linear Rational linear inequality Real polynomial inequality Boolean equality Boolean order atomless Boolean equality and inequality

4 4 9.2 Evaluation of Relational Algebra Queries points(DB) – the logical level infinite relation/database that is equivalent to the constraint relation/database DB. For any relational algebra operator/query O on infinite databases we can always find a finitely evaluable relational algebra operator/query ô on constraint databases such that: O(points(DB)) = points( ô (DB))

5 5 XY xyx – y ≥ 5 A XY xyx + y < 9 XY xyx – y ≥ 5, x + y < 9 XY xyx – y ≥ 5 XYx + y < 9 B C D C = A ∩ B ^ D = A υ B ^ Example:

6 6 XY xy x – y ≥ 5, x + y  9 XY xyx ≥ 7 E F E = A – B ^ F =  x E =  y E ^ Example:

7 7 9.3 Evaluation of SQL queries Max/Min evaluated by linear programming if all constraints are linear inequalities. Example: SELECT Min(x) FROM E will return 7.

8 8 Constraint instantiation – substitution of rule body relation symbols by constraint tuples. Constraint proof – constraint tuple t 0  R 0 can be proven in query Q and database instance I, written t |  Q,I R 0, if –t  R 0, or –there is a constraint instantiation t 0 (...) :– t 1 (…), …, t n (…). where t i |  Q,I R i for 1 ≤ i ≤ n and t 0 =  * t 1 (…), …, t n (…) where * are variables that appear only in the rule body. 9.4 Evaluation of Datalog Queries

9 9 Theorem: The proof-based and the constraint proof-based semantics are equivalent. {(a 1,…,a n ): |  Q,I R(a 1,….,a k )} = {points(t): |  Q,I t  R}

10 10 Repeat do constraint rule instantiation using the constraint tuples already in the DB evaluate the rule, using variable elimination add the derived constraint tuple to the DB, if it is at least partially new Until any tuple is added to DB The goal is to prove termination of the above algorithm. Datalog evaluation algorithm

11 11 Evaluation terminates (in closed-form) for: Infinite domain equality and inequality Rational order Integer/rational half-addition, lower and upper bound Integer/rational gap-order, upper bound, positive linear Boolean order

12 12 Approximate evaluation for integer/rational addition – Let l be a fixed negative constant. We modify in each constraint tuple each constraint with bound b < l by: changing b to l to get a lower bound Q(D) l deleting the constraint to get an upper bound Q(D) l The approximate evaluation terminates and returns correct upper and lower bounds, that is, Q(D) l  Q(D)  Q(D) l also, for any l 1 and l 2 such that l 1 ≤ l 2 < 0: Q(D) l 2  Q(D) l 1 and Q(D) l 1  Q(D) l 2


Download ppt "1 9. Evaluation of Queries Query evaluation –. 2 9.1 Quantifier Elimination and Satisfiability Example: Logical Level: r   y 1,…y n  r’ Constraint."

Similar presentations


Ads by Google