NOT(s.StudentNumbe
r=
g.StudentNumber) OR g.Grad
e=
'A' ) }
Domain relational Calculus:
{ ad | (EXISTS b) ( STUDENT(abcd) AND (FORALL e) (FORALL g) (
NOT(GRADE_REPORT(efg)) OR NOT(
b=
e) OR
g=
'A' ) ) }
(f) Retrieve the names and major departments of all students who do not have any grade
of A in any of their courses.
Tuple relational Calculus:
{ s.Name, s.Major | STUDENT(s) AND NOT(EXISTS g)
( GRADE_REPORT(g) AND
s.StudentNumber=g.StudentNumber AND g.Grade='A' ) }
Domain relational Calculus:
{ ad | (EXISTS b) ( STUDENT(abcd) AND NOT(EXISTS e) NOT(EXISTS g) (
GRADE_REPORT(efg)
AND
b=
e AND
g=
'A' ) ) }
6.27 In a tuple relational calculus query with n tuple variables, what would be the
typical minimum number of join conditions? Why? What is the effect of having a
smaller number of join conditions?
Answer:
Typically, there should be at least (n-1) join conditions; otherwise, a cartesian product
with one of the range relations would be taken, which usually does not make sense.
6.28 Rewrite the domain relational calculus queries that followed Q0 in Section 6.7 in
the style of the abbreviated notation of Q0A, where the objective is to minimize
the number of domain variables by writing constants in place of variables
wherever possible.
Answer
:
Q1A: { qsv | (EXISTS z) (EXISTS m) ( EMPLOYEE(q,r,s,t,u,v,w,x,y,z) AND
DEPARTMENT('Research',m,n,o) AND m=z ) }
Q2A: { iksuv | (EXISTS m) (EXISTS n) (EXISTS t) ( PROJECT(h,i,'Stafford',k)
AND
EMPLOYEE(q,r,s,t,u,v,w,x,y,z) AND DEPARTMENT(l,m,n,o) ) }
The other queries will not be different since they have no constants (no selection
conditions; only join conditions)
6.30 Show how you may specify the following relational algebra operations in both
tuple and domain relational calculus.
(a) SELECT A=c (R(A, B, C)):
(b) PROJECT <A, B> (R(A, B, C)):
(c) R(A, B, C) NATURAL JOIN S(C, D, E):
(d) R(A, B, C) UNION S(A, B, C):
(e) R(A, B, C) INTERSECT S(A, B, C):
(f) R(A, B, C) MINUS S(A, B, C):