cs345-4

cs345-4 - 1 Extended Conjunctive Queries Unions Arithmetic...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Extended Conjunctive Queries Unions Arithmetic Negation 2 Containment of Unions of CQ’s ◆ Theorem: P 1 ∪ … ∪ P k ⊆ Q 1 ∪ … ∪ Q n if and only if for each P i there is some Q j such that P i ⊆ Q j . ◆ Proof (if): Obvious. 3 Proof of “Only-If” ◆ Assume P 1 ∪ … ∪ P k ⊆ Q 1 ∪ … ∪ Q n . ◆ Let D be the canonical (frozen) DB for P i . ◆ Since the containment holds, and P i ( D ) includes the frozen head of P i , there must be some Q j such that Q j ( D ) also includes the frozen head of P i . ◆ Thus, P i ⊆ Q j . 4 CQ Contained in Datalog Program ◆ Let Q be a CQ and P a Datalog program. ◆ Each returns a relation for each EDB database D , so it makes sense to ask if Q ⊆ P . ◗ That is, Q ( D ) ⊆ P ( D ) for all D . 5 The Containment Test ◆ Let D be the canonical DB for Q . ◆ Compute P ( D ), and test if it contains the frozen head of Q. ◆ If so, Q ⊆ P ; if not, D is a counterexample. 6 Example Q : p(X,Y) :- a(X,Z) & a(Z,W) & a(W,Y) P : p(X,Y) :- a(X,Y) p(X,Y) :- p(X,Z) & p(Z,Y) ◆ Intuitively: Q = paths of length 3; P = all paths. ◆ Frozen Q : D = {a(x,z), a(z,w), a(w,y)}. 7 Example --- Continued D = {a(x,z), a(z,w), a(w,y)} P : p(X,Y) :- a(X,Y) p(X,Y) :- p(X,Z) & p(Z,Y) ◆ Infer by first rule: p(x,z), p(z,w), p(w,y). ◆ Infer by second rule: p(x,w), p(z,y), p(x,y)....
View Full Document

This document was uploaded on 01/06/2012.

Page1 / 31

cs345-4 - 1 Extended Conjunctive Queries Unions Arithmetic...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online