Docsity

Problem Set: Translation and Magic Set Rules for Arithmetic Expressions, Exercises of Distributed Database Management Systems

Toggle sidebar
bg1
CS345A PROBLEM SET #4
Due in class, Wednesday,May 4, 1994
1) (15 points) Sorry | I should have included this question with Problem Set 3. Suppose
wehave the relation
R
whose value is the four tuples:
R
1
R
2
a b
f
(
a
)
g
(
b
)
f
;
g
(
a
)
๎˜‚
g
;
f
(
b
)
๎˜‚
f
;
f
(
a
)
๎˜‚
f
(
a
)
Perform the following translations.
a)
Q
(
X๎˜‚ Y
)=
ATOV
๎˜ƒ
p
;
f
(
X
)
๎˜‚g
(
Y
)
๎˜‚
๎˜‚R
๎˜„
.
b)
Q
(
X๎˜‚ Y
)=
ATOV
๎˜ƒ
p
;
f
(
X
)
๎˜‚X
๎˜‚
๎˜‚R
๎˜„
.
c)
P
=
VTOA
๎˜ƒ
p
;
h
(
X๎˜‚ Y
)
๎˜‚g
(
X
)
๎˜‚
๎˜‚R
(
X๎˜‚ Y
)
๎˜„
.
2) (10 points) Consider the rules
p(X,Y,Z) :- q(X,Y,Z)
p(X,Y,Z) :- p(X,A,Y) & p(Y,B,Z)
Draw the rule/goal graph starting with the adorned goal
p
bff
.
3) (15 points) For the rules of Problem (2) and the query
p
(0
๎˜‚U๎˜‚V
), write the magic-set
rules, using the basic method of Section 13.1.
4) (10 points) Repeat Problem 3 using the \simpli๎˜“ed" metho d of Section 13.4.
5) (20 points) Below are rules that de๎˜“ne terms representing the structure of arithmetic
expressions with +,
๎˜€
, and parentheses.
expression(plus(E,T))) :- expression(E) & product(T).
expression(E) :- product(E).
product(times(T,F)) :- product(T) & factor(F).
product(T) :- factor(T).
factor(parens(E)) :- expression(E).
factor(F) :- identifier(F).
Write the magic-set rules for the query form
expression
b
. For Group V you may
imagine that the query is about some term
e
0
, whichwe are testing to see if it has the
correct form of an expression. You may use either the \basic" or \simpli๎˜“ed" metho d.
1
docsity.com

Partial preview of the text

Download Problem Set: Translation and Magic Set Rules for Arithmetic Expressions and more Exercises Distributed Database Management Systems in PDF only on Docsity!

CSA PROBLEM SET  Due in class Wednesday May  

  p oints Sorry I should have included this question with Problem Set Supp ose we have the relation R whose value is the four tuples

R R a b f a g b f

g a

g

f b

f

f a

f a Perform the following translations

a QX  Y  ATOV

p

f X  g Y 

 R

b QX  Y  ATOV

p

f X  X

 R

c P VTOA

p

hX  Y  g X 

 RX  Y 

  p oints Consider the rules

pXYZ  qXYZ pXYZ  pXAY  pYBZ Draw the rulegoal graph starting with the adorned goal pbf^ f

  p oints For the rules of Problem  and the query p U V  write the magicset rules using the basic metho d of Section  

  p oints Rep eat Problem using the simplied metho d of Section  

  p oints Below are rules that dene terms representing the structure of arithmetic expressions with   and parentheses expressionplusET  expressionE  productT expressionE  productE producttimesTF  productT  factorF productT  factorT factorparensE  expressionE factorF  identifierF

Write the magicset rules for the query form expr essionb^ For Group V you may imagine that the query is ab out some term e  which we are testing to see if it has the correct form of an expression You may use either the basic or simplied metho d

docsity.com