Conjunctive Queries
Conjunctive Queries
Conjunctive Queries
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
QueryHomomorphisms<br />
(akaContainmentMappings)<br />
Example<br />
Amappingfromthevariables ofCQQ2to<br />
thevariablesofCQQ1,suchthat:<br />
TheheadofQ2ismappedtotheheadofQ1.<br />
Q1:p(X,Y) r(X,Z),g(Z,Z),r(Z,Y)<br />
Q2:p(A,B) r(A,C),g(C,D),r(D,B)<br />
Eachsubgoal (=bodyatom)ofQ2ismappedto<br />
somesubgoal ofQ1withthesamepredicate.<br />
HomomorphismTheorem:<br />
ThereisahomomorphismfromQ2toQ1if<br />
andonlyifQ1 Q2.<br />
21<br />
Q1looksfor:<br />
X<br />
Q2looksfor:<br />
A<br />
Z<br />
C<br />
Y<br />
D<br />
SinceC=Dispossible,<br />
expectQ1 Q2.<br />
B<br />
22<br />
Example Continued<br />
• WheneverthereisapathfromX toY,it<br />
mustbethatX hasanarcout,andY an<br />
arcin.<br />
• Thus,everyfact(tuple)producedbyQ1is<br />
alsoproducedbyQ2.<br />
•Thatis,Q1 Q2.<br />
Example Continued<br />
Q1: p(X,Y) r(X,Z) , g(Z,Z) , r(Z,Y)<br />
Q2: p(A,B) r(A,C) , g(C,D) , r(D,B)<br />
Homomorphism:h(A)=X;h(B)=Y;h(C)=h(D)=Z.<br />
23<br />
24