9. Evaluation of Queries - PowerPoint PPT Presentation

About This Presentation
Title:

9. Evaluation of Queries

Description:

9. Evaluation of Queries Query evaluation – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 13
Provided by: Syed90
Learn more at: http://cse.unl.edu
Category:

less

Transcript and Presenter's Notes

Title: 9. Evaluation of Queries


1
9. Evaluation of Queries
  • Query evaluation

2
  • 9.1 Quantifier Elimination and Satisfiability
  • Example
  • Logical Level r ? ? y1,yn
    ? r
  • Constraint level S ? eliminate x
    ? S
  • Infinite relation r(x, y1,yn) equivalent to
    constraint relation S.
  • Infinite relation r(y1,yn) 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
  • 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
  • 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
Example
A
B
X Y
x y x y 5
X Y
x y x y lt 9
C
X Y
x y x y 5, x y lt 9

C A n B
D
X Y
x y x y 5
X Y x y lt 9

D A ? B
6
Example
E
X Y
x y x y 5, x y ? 9

E A B
F
X Y
x y x 7

F ?x E ?y E
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
9.4 Evaluation of Datalog Queries
  • Constraint instantiation substitution of rule
    body relation
  • symbols
    by constraint tuples.
  • Constraint proof constraint tuple t0 ? R0 can
    be proven in
  • query Q and database instance I,
    written t ?Q,I R0, if
  • t ? R0, or
  • there is a constraint instantiation
  • t0(...) t1(), , tn().
  • where ti ?Q,I Ri for 1 i n and
  • t0 ? t1(), , tn()
  • where are variables that appear only in
    the rule body.

9
  • Theorem
  • The proof-based and the constraint proof-based
    semantics
  • are equivalent.
  • (a1,,an) ?Q,I R(a1,.,ak)
    points(t) ?Q,I t ? R

10
Datalog evaluation algorithm
  • 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.

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
  • Approximate evaluation for integer/rational
    addition
  • Let l be a fixed negative constant. We
    modify in each
  • constraint tuple each constraint with bound
    b lt 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 l1 and l2 such that l1 l2 lt 0
Q(D)l2 ? Q(D) l1 and Q(D)l1 ? Q(D)l2
Write a Comment
User Comments (0)
About PowerShow.com