Docsity

Datalog Rules, Minimal Model and EDB-Distributed Queries-Assignment, Exercises of Distributed Database Management Systems

Toggle sidebar
bg1
CS345A PROBLEM SET #1
Due in class, Monday, April 11, 1994
6 Questions, 90 pts.
1) (10 points) Consider the rule
q(X) :- e(A,B,X) & p(A) & p(B).
Suppose the relation
P
for
p
contains the (unary) tuples
f
(1)
๎˜‚
(2)
๎˜‚
(3)
g
, and the tuples
in the relation
E
for
e
are
f
(1
๎˜‚
2
๎˜‚
4)
๎˜‚
(3
๎˜‚
4
๎˜‚
5)
๎˜‚
(2
๎˜‚
3
๎˜‚
4)
๎˜‚
(3
๎˜‚
1
๎˜‚
6)
g
. What is the value of
the relation
Q
for
q
?For each tuple of
Q
, give a substitution of constants for variables
that explains why that tuple is in
Q
.
2) (15 points) (Exercise 3.5 from PDKS-I) The following is a simpli๎˜cation of a calcu-
lation that must be performed in an optimizing compiler. We shall assume that all
procedures of the hypothetical language being compiled have a single parameter, and
an EDB relation
param
(
P๎˜‚ X
)says that
X
is the formal parameter of procedure
P
.
Another EDB predicate
calls
(
P๎˜‚ Q๎˜‚ Y
)says that procedure
P
calls procedure
Q
with
actual parameter
Y
. It is possible that
Y
is a local variable of
P
, the formal parameter
of
P
, or a constant. For example, the procedures in Figure A are characterized by the
EDB facts
param
(
p๎˜‚ x
)
calls
(
p๎˜‚ q๎˜‚ a
)
param
(
q๎˜‚ y
)
calls
(
p๎˜‚ q๎˜‚ x
)
calls
(
q๎˜‚ p๎˜‚ y
)
calls
(
q๎˜‚ q๎˜‚
3)
Write Datalog rules that compute the \transitive closure" of
calls
, that is, an IDB
predicate
calls star
(
P๎˜‚ Q๎˜‚ Z
) that says when procedure
P
executes, it results in a
call to
Q
with argument
Z
, p erhaps through a sequence of calls to procedures. For
example, in the procedures of Figure A,
calls star
(
p๎˜‚ p๎˜‚ a
) is true, b ecause
p
calls
q
with argument
a
, and
q
calls
p
with its own formal parameter as argument.
procedure
p(x)๎˜‰
local a๎˜‰
call q(a)๎˜‰
call q(x)๎˜‰
end
procedure
q(y)๎˜‰
call p(y)๎˜‰
call q(3)๎˜‰
end
Fig. A.
Example program for Problem 2.
1
docsity.com
pf2

Partial preview of the text

Download Datalog Rules, Minimal Model and EDB-Distributed Queries-Assignment and more Exercises Distributed Database Management Systems in PDF only on Docsity!

CSA PROBLEM SET  Due in class Monday April    Questions  pts

  p oints Consider the rule

qX  eABX  pA  pB Supp ose the relation P for p contains the unary tuples f    g and the tuples in the relation E for e are f               g What is the value of the relation Q for q  For each tuple of Q give a substitution of constants for variables that explains why that tuple is in Q  p oints Exercise  from PDKSI The following is a simplication of a calcu lation that must b e p erformed in an optimizing compiler We shall assume that all pro cedures of the hyp othetical language b eing compiled have a single parameter and an EDB relation par am P  X says that X is the formal parameter of pro cedure P  Another EDB predicate cal l s P  Q Y says that pro cedure P calls pro cedure Q with actual parameter Y  It is p ossible that Y is a lo cal variable of P  the formal parameter of P  or a constant For example the pro cedures in Figure A are characterized by the EDB facts par am p x cal l s p q  a par am q  y cal l s p q  x cal l s q  p y cal l s q  q  Write Datalog rules that compute the transitive closure of cal l s that is an IDB predicate cal l s star P  Q Z that says when pro cedure P executes it results in a call to Q with argument Z  p erhaps through a sequence of calls to pro cedures For example in the pro cedures of Figure A cal l s star p p a is true b ecause p calls q with argument a and q calls p with its own formal parameter as argument

pro cedure px local a call qa call qx end pro cedure qy call py call q  end

Fig A Example program for Problem 

docsity.com

 p oints Exercise  of PDKSI Supp ose we have EDB relations f r eq uents D r ink er B ar ser v es B ar B e er l ik es D r ink er B eer

The rst indicates the bars a drinker visits the second tells what b eers each bar serves and the last indicates which b eers each drinker likes to drink Dene the following predicates using safe Datalog rules

a happy D that is true if drinker D frequents at least one bar that serves a b eer he or she likes

b shoul dV isit D  B if bar B serves a b eer drinker D likes

  p oints Write each of the queries

a v er y H appy D if every bar that drinker D frequents serves at least one b eer he or she likes You may assume that every drinker frequents at least one bar b sad D if drinker D frequents no bar that serves a b eer he or she likes

In i domain relational calculus and ii tuple relational calculus For each of a and b   p oints is awarded for getting the idea and p oints for rendering the idea correctly in DRC and TRC p oints Exercise  from PDKSI 

Consider the rules pXY  qXY  not rX rX  sXY  not tY rX  sXY  rY

a Determine the stratum of each predicate Is the program stratied b Supp ose the relations for the EDB predicates s t and q are resp ectively S  fab bc cag T  fa b cg and Q  fab bc cd deg Find the stratied p erfect mo del for the IDB predicates p and r  given this EDB c Find another minimal mo del for the rules and the EDB given in b 

docsity.com