# Tuple relational calculus elname efname employeee and

• Notes
• 10
• 100% (7) 7 out of 7 people found this document helpful

This preview shows pages 6–9. Sign up to view the full content.

Tuple relational Calculus:

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

{ e.LNAME, e.FNAME | EMPLOYEE(e) AND (FORALL p) ( NOT(PROJECT(p)) OR (EXISTS w) ( WORKS_ON(w) AND p.PNUMBER=w.PNO AND w.ESSN=e.SSN ) ) } Domain relational Calculus: { qs | (EXISTS t) ( EMPLOYEE(qrstuvwxyz) AND (FORALL b) ( NOT(PROJECT(abcd)) OR (EXISTS e) (EXISTS f) (WORKS_ON(efg) AND e=t AND f=b) ) } (f) Retrieve the names of employees who do not work on any project. Tuple relational Calculus: { e.LNAME, e.FNAME | EMPLOYEE(e) AND NOT(EXISTS w) ( WORKS_ON(w) AND w.ESSN=e.SSN ) } Domain relational Calculus: { qs | (EXISTS t) ( EMPLOYEE(qrstuvwxyz) AND NOT(EXISTS a) ( WORKS_ON(abc) AND a=t ) ) } (i) Find the names and addresses of employees who work on at least one project located in Houston but whose department has no location in Houston. Tuple relational Calculus: { e.LNAME, e.FNAME, e.ADDRESS | EMPLOYEE(e) AND (EXISTS p) (EXISTS w) ( WORKS_ON(w) AND PROJECT(p) AND e.SSN=w.ESSN AND w.PNO=p.PNUMBER AND p.PLOCATION='Houston' AND NOT(EXISTS l) ( DEPT_LOCATIONS(l) AND e.DNO=l.DNUMBER AND l.DLOCATION='Houston' ) ) } Domain relational Calculus: { qsv | (EXISTS t) (EXISTS z) ( EMPLOYEE(qrstuvwxyz) AND (EXISTS b) (EXISTS c) (EXISTS e) (EXISTS f) ( WORKS_ON(efg) AND PROJECT(abcd) AND t=e AND f=b AND c='Houston' AND NOT(EXISTS h) NOT(EXISTS i) ( DEPT_LOCATIONS(hi) AND z=h AND i='Houston' ) ) } (j) List the last names of department managers who have no dependents. Tuple relational Calculus: { e.LNAME | EMPLOYEE(e) AND (EXISTS d) ( DEPARTMENT(d) AND e.SSN=d.MGRSSN AND NOT(EXISTS x) (DEPENDENT(x) AND e.SSN=x.ESSN) ) } Domain relational Calculus: { s | (EXISTS t) ( EMPLOYEE(qrstuvwxyz) AND (EXISTS c) ( DEPARTMENT(abcd) AND t=c AND NOT(EXISTS e) (DEPENDENT(efghi) AND e=t) ) } 6.25 No solution provided.
6.26 Specify queries of Exercise 6.18 in both the tuple relational calculus and the domain relational calculus. Also specify these queries in the relational algebra. Answer: We will only do tuple and domain relational calculus here. (a) Retrieve the names of all senior students majoring in 'COSC' (computer science). Tuple relational Calculus : { s.Name | STUDENT(s) AND AND s.Class=5 AND s.Major='COSC' } Domain relational Calculus: { a | (EXISTS c) (EXISTS d) ( STUDENT(abcd) AND c=5 AND d='COSC' ) } (b) Retrieve the names of all courses taught by professor King in 85 and 86. Tuple relational Calculus: { c.CourseName | COURSE(c) AND (EXISTS s) ( SECTION(s) AND c.CourseNumber=s.CourseNumber AND s.Instructor='King' AND ( s.Year='85' OR s.Year='86' ) ) } Domain relational Calculus: { a | (EXISTS b) (EXISTS f) (EXISTS h) (EXISTS i) ( COURSE(abcd) AND SECTION(efghi) AND f=b AND i='King' AND ( h='85' OR h='86' ) ) } (c) For each section taught by professor King, retrieve the course number, semester, year, and number of students who took the section. This query cannot be done in basic relational calculus as it requires a COUNT function. (d) Retrieve the name and transcript of each senior student (Class=5) majoring in COSC. Transcript includes course name, course number, credit hours, semester, year, and grade for each course completed by the student. Tuple relational Calculus: {s.Name, c.CourseName, c.CourseNumber, c.CreditHours, t.Semester, t.Year, g.Grade | STUDENT(s) AND COURSE(c) AND SECTION(t) AND GRADE_REPORT(g) AND s.Class=5 AND s.Major='COSC' AND s.StudentNumber=g.StudentNumber AND g.SectionIdentifier=t.SectionIdentifier AND t.CourseNumber=c.CourseNumber} Domain relational Calculus: {aefgklp | (EXISTS b) (EXISTS c) (EXISTS d) (EXISTS n) (EXISTS o) (EXISTS j) (EXISTS i) (STUDENT(abcd) AND COURSE(efgh) AND SECTION(ijklm) AND GRADE_REPORT(nop) AND c=5 AND d='COSC' AND b=n AND i=o AND j=f)} (e) Retrieve the names and major departments of all straight A students (students who have a grade of A in all their courses).

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

This is the end of the preview. Sign up to access the rest of the document.
• Fall '08
• 5odfatrek
• It, Relational model, Domain relational calculus, Relational calculus, Tuple relational calculus

{[ 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