Docsity

Equivalances and Containment-Handling Distributed Queries-Assignment, Exercises of Distributed Database Management Systems

Toggle sidebar
bg1
CS345A PROBLEM SET #5
Due in class, Wednesday,May 11, 1994
1) (10 points) Consider the conjunctive queries
Q
1
: p(A,B) :- q(A,C) & r(C,B).
Q
2
: p(A,B) :- q(B,D) & r(D,A).
Does the symbol mapping
๎˜‚
(
B
)=
A
,
๎˜‚
(
D
)=
C
,and
๎˜‚
(
A
)=
B
demonstrate that
Q
1
๎˜€
Q
2
?Whyorwhy not?
2) (30 points) Find all equivalences and containments among the four conjunctive queries
below. Note that
c
is a constantin
Q
4
.
Q
1
: p(X,Y) :- arc(X,A) & arc(A,B) & arc(B,Y)
Q
2
: p(X,Y) :- arc(X,A) & arc(A,B) & arc(B,C) & arc(C,Y)
Q
3
: p(X,Y) :- arc(X,A) & arc(B,C) & arc(D,Y) &
arc(X,B) & arc(A,C) & arc(C,Y)
Q
4
: p(X,Y) :- arc(X,A) & arc(A,c) & arc(c,B) & arc(B,Y)
3) (20 points) Consider the in๎˜Žnite union of conjunctive queries
Q
1
๎˜‚
Q
2
๎˜‚๎˜ƒ๎˜ƒ๎˜ƒ
,where
Q
k
is
p(X) :- arc(X,Z
1
)&arc(Z
1
,Z
2
) & ... & arc(Z
k
;
1
Z
k
) & arc(Z
k
,X)
Note that
Q
k
represents (not necessarily simple) cycles of length
k
+ 1 in a directed
graph. Find all containments among the
Q
's.
4) (20 points) Determine whether each of the conjunctive queries
p(X,Y) :- arc(X,A) & arc(A,Y) & arc(X,B) &
arc(B,Y) & X<A & B<Y.
p(X,Y) :- arc(X,Z) & arc(Z,Y) & X<Z & Z<Y.
is contained in the other. If not, give a counterexample.
Hint
: The Gupta test is
messy here, since there are a lot of containment mappings after we replace duplicate
occurrences of variables. However, in general, and here in particular, when there is
implication of the OR over all containment mappings, we can usually identify one or a
few of the containment mappings that are really involved in the implication. Try ๎˜Žrst
to understand what the CQ's are saying, and then focus on the containment mappings
you really need.
5) (20 points) Consider the logic program
P
consisting of the rules
p(X,Y,Z) :- q(X,Y,Z).
p(X,Y,Z) :- p(A,A,A) & p(A,X,Y) &
s(X) & s(Y) & s(Z) & s(A).
and the conjunctive query
1
docsity.com
pf2

Partial preview of the text

Download Equivalances and Containment-Handling Distributed Queries-Assignment and more Exercises Distributed Database Management Systems in PDF only on Docsity!

CSA PROBLEM SET  Due in class Wednesday May  

  p oints Consider the conjunctive queries

Q pAB  qAC  rCB Q pAB  qBD  rDA

Do es the symb ol mapping  B  A  D  C  and  A B demonstrate that Q Q Why or why not

   p oints Find all equivalences and containments among the four conjunctive queries b elow Note that c is a constant in Q Q pXY  arcXA  arcAB  arcBY Q pXY  arcXA  arcAB  arcBC  arcCY Q pXY  arcXA  arcBC  arcDY  arcXB  arcAC  arcCY Q pXY  arcXA  arcAc  arccB  arcBY

   p oints Consider the innite union of conjunctive queries Q  Q      where Qk is

pX  arcXZ   arcZ Z     arcZk Zk   arcZk X

Note that Qk represents not necessarily simple cycles of length k   in a directed graph Find all containments among the Qs

   p oints Determine whether each of the conjunctive queries

pXY  arcXA  arcAY  arcXB  arcBY  XA  BY pXY  arcXZ  arcZY  XZ  ZY

is contained in the other If not give a counterexample Hint  The Gupta test is messy here since there are a lot of containment mappings after we replace duplicate o ccurrences of variables However in general and here in particular when there is implication of the OR over all containment mappings we can usually identify one or a few of the containment mappings that are really involved in the implication Try rst to understand what the CQs are saying and then fo cus on the containment mappings you really need

   p oints Consider the logic program P consisting of the rules

pXYZ  qXYZ pXYZ  pAAA  pAXY  sX  sY  sZ  sA

and the conjunctive query

docsity.com

Q pXYZ  qBBB  qBAA  qAXY  sX  sY  sZ  sA  sB

Show that Q P

docsity.com