CS
Chapter08ARelationalAlgebra (1).pptx

# This operation will take the union of tuples in two

• 65

This preview shows pages 62–65. Sign up to view the full content.

This operation will take the union of tuples in two relations R(X, Y) and S(X, Z) that are partially compatible , meaning that only some of their attributes, say X, are type compatible. The attributes that are type compatible are represented only once in the result, and those attributes that are not type compatible from either relation are also kept in the result relation T(X, Y, Z). Relational Algebra and Calculus 62

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

Outer Union Operations Example: An outer union can be applied to two relations whose schemas are STUDENT(Name, SSN, Department, Advisor) and INSTRUCTOR(Name, SSN, Department, Rank). Tuples from the two relations are matched based on having the same combination of values of the shared attributes— Name, SSN, Department. If a student is also an instructor, both Advisor and Rank will have a value; otherwise, one of these two attributes will be null. The result relation STUDENT_OR_INSTRUCTOR will have the following attributes: STUDENT_OR_INSTRUCTOR (Name, SSN, Department, Advisor, Rank) Relational Algebra and Calculus 63
Examples of Queries in Relational Algebra: Procedural Form Q1: Retrieve the name and address of all employees who work for the ‘Research’ department. RESEARCH_DEPT DNAME=’Research’ (DEPARTMENT) RESEARCH_EMPS (RESEARCH_DEPT DNUMBER= DNOEMPLOYEE EMPLOYEE) RESULT FNAME, LNAME, ADDRESS (RESEARCH_EMPS) Q6: Retrieve the names of employees who have no dependents. ALL_EMPS SSN (EMPLOYEE) EMPS_WITH_DEPS ( SSN ) ESSN ( DEPENDENT ) EMPS_WITHOUT_DEPS (ALL_EMPS - EMPS_WITH_DEPS) RESULT LNAME, FNAME (EMPS_WITHOUT_DEPS * EMPLOYEE) Relational Algebra and Calculus 64

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

Examples of Queries in Relational Algebra: Single expressions As a single expression, these queries become: Q1: Retrieve the name and address of all employees who work for the ‘Research’ department. Fname, Lname, Address (σ Dname= ‘Research’ (DEPARTMENT Dnumber=Dno(EMPLOYEE)) Q6: Retrieve the names of employees who have no dependents. Lname, Fname (( Ssn (EMPLOYEE) − ρ Ssn ( Essn (DEPENDENT))) EMPLOYEE) Relational Algebra and Calculus 65
This is the end of the preview. Sign up to access the rest of the document.
• Fall '09
• SUNANHAN

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