Professional Documents
Culture Documents
Chapter 2
Chapter 2
Navathe Slide 6- 1
Chapter 2
The Relational Algebra
SELECT (symbol: (sigma))
PROJECT (symbol: (pi))
RENAME (symbol: (rho))
Relational Algebra Operations From Set Theory
UNION ( ), INTERSECTION ( ), DIFFERENCE (or MINUS, – )
CARTESIAN PRODUCT ( x )
Binary Relational Operations
JOIN (several variations of JOIN exist)
DIVISION
Additional Relational Operations
OUTER JOINS, OUTER UNION
AGGREGATE FUNCTIONS (These compute summary of
information: for example, SUM, COUNT, AVG, MIN, MAX)
DNO = 4 (EMPLOYEE)
Select the employee tuples whose salary is greater than $30,000:
SALARY > 30,000 (EMPLOYEE)
operations
Necessary in some cases (see JOIN operation
later)
DEPT_MGR DEPARTMENT MGRSSN=SSN EMPLOYEE
MGRSSN=SSN is the join condition
Combines each department record with the employee who
manages the department
The join condition can also be specified as (table name.field name)
DEPARTMENT.MGRSSN= EMPLOYEE.SSN
SMITH FNAME ' John ' AND LNAME 'Smith ' ( EMPLOYEE )
SMITH _ PNOS PNO (WORKS _ ON ESSN SSN SMITH )
SSN _ PNOS ESSN , PNO (WORKS _ ON )
SSNS ( SSN ) SSN _ PNOS ÷ SMITH_PNOS
RESULT FNAME , LNAME ( SSNS * EMPLOYEE )
?
5: List the names of all employees with two or more dependents. (Assume that
dependents of the same employee have distinct DEPENDENT_NAME values)
?
8: List all employee names and the name of the departments they manage if they
happen to manage a department.
?