# Tuple relational calculus sname smajor students and

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

Tuple relational Calculus: { s.Name, s.Major | STUDENT(s) AND (FORALL g) ( NOT(GRADE_REPORT(g)) OR

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

View Full Document
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):
(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 ) }
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern