{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Tuple relational calculus sname smajor students and

Info iconThis preview shows pages 8–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Tuple relational Calculus: { s.Name, s.Major | STUDENT(s) AND (FORALL g) ( NOT(GRADE_REPORT(g)) OR
Background image of page 8

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
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):
Background image of page 9
(g) R(A, B, C) CARTESIAN PRODUCT S(D, E, F): (h) R(A, B) DIVIDE S(A): Answer: For each operation, we give the tuple calculus expression followed by the domain calculus expression. (a) { t | R(t) AND t.A=c}, { xyz | R(xyz) AND x=c } (b) { t.A, t.B | R(t) }, { xy | R(xyz) } (c) {t.A, t.B, t.C, q.D, q.E | R(t) AND S(q) AND t.C=q.C }, { xyzvw | R(xyz) AND (EXISTS u) ( S(uvw) AND z=u ) } (d) { t | R(t) OR S(t) }, { xyz | R(xyz) OR S(xyz) } (e) { t | R(t) AND S(t) }, { xyz | R(xyz) AND S(xyz) } (f) { t | R(t) AND NOT(S(t)) }, { xyz | R(xyz) AND NOT(S(xyz)) } (g) { t.A, t.B, t.C, q.D, q.E, q.F | R(t) AND S(q) }, ( xyzuvw | R(xyz) AND S(uvw) } (h) { t.B | R(t) AND (FORALL s) ( NOT(S(s)) OR (EXISTS q) ( R(q) AND s.A=q.A AND q.B=t.B ) ) }, { y | R(xy) AND (FORALL z) ( NOT(S(z)) OR (EXISTS u) ( R(uy) AND z=u ) }
Background image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}