Conjunctive Queries
Conjunctive Queries
Conjunctive Queries
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
CQContainmentvs.<br />
BCQevaluation<br />
• BothareNPcomplete,but:<br />
– thepotentialnumberofmappingsisdifferent:<br />
n m :wheren is<br />
•thesizeofQ1forCQcontainment(small,and<br />
normallydoesnothurt)<br />
•isthesizeofadatabaseforBCQevaluation(couldbe<br />
huge)<br />
• Highlydesirable:IdentifyfragmentsofBCQ,<br />
whoseevaluationproblemistractable(inP).<br />
53<br />
BCQevaluation<br />
• Intuition:theproblemwithcyclesinthequery:<br />
– Considerthequeries:<br />
•Q1:ans e(A,B),e(B,C),e(C,D),e(D,A)<br />
•Q2:ans e(A,B),e(B,C),e(C,D),e(D,E)<br />
•InprocessingQ1,maintainintermediatejoin<br />
resultse’(A,B,C,D) e(D,A)<br />
•InprocessingQ2,allthejoinoperationsareonly<br />
betweentwopredicates(locally)<br />
54<br />
Hypergraph of Crossword Puzzle<br />
<strong>Queries</strong>, CSPs, and<br />
Hypergraphs<br />
ans Enrolled(S,C,R) Teaches(P,C,A) Parent(P,S)<br />
C<br />
R<br />
A<br />
Theorem:Theevilisinthecycles.<br />
S<br />
P