

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















Unary Relational Operations (^) 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 (SUM, COUNT, AVG, MIN, MAX))
1.First and last names of all department managers. 2.Salaries of all employees who have worked on the Reorganization project. 3.SSN of all employees who have worked on a project that is controlled by a department different than the department that they are assigned to. 4.Last name of all employees who are not married.
Rename the attributes of a relation or change the relation name The general RENAME operation :
shorthand for renaming attributes : R1 FNAME, LNAME, SALARY (DEP5_EMPS)) R1 has same attribute names as DEP5_EMPS R2 (F,L,S)) ( FNAME, LNAME, SALARY (DEP5_EMPS)))) R2 has attributes renamed to F, L and S R3 (F,L,S)) FNAME, LNAME, SALARY (DEP5_EMPS))
Symbol for aggregate functions is ℱ (^) ℱ MAX Salary (EMPLOYEE)) retrieves the maximum salary value from the EMPLOYEE relation (^) ℱ MIN Salary (EMPLOYEE)) retrieves the minimum Salary value from the EMPLOYEE relation (^) ℱ SUM Salary (EMPLOYEE)) retrieves the sum of the Salary from the EMPLOYEE relation (^) ℱ COUNT SSN, AVERAGE Salary (EMPLOYEE)) computes the number of employees and their average salary
Grouping can be combined with Aggregate Functions Example: (^) For each department, retrieve the DNO, COUNT SSN, and AVERAGE SALARY DNO ℱCOUNT SSN, AVERAGE Salary (EMPLOYEE)) Group employees by DNO, then compute aggregate functions on each group
Example: (^) Retrieve names of employees who work on all projects that John Smith works on. R = S T x ϵ R, iff for every y ϵ T, <x,y> ϵ S The tuples in R come from the tuples in S that match every tuple in T
T has all attributes of R that are not in S. Find tuples in R that match every tuple in S. Project the attributes that are not in S.
R = S T can be computed as R1 = Y(S)) R2 = Y((T X R1)) – S)) R = R1 – R
Equijoin Natural join Outer join Outer union
The most common use of join involves join conditions with equality comparisons only When the only comparison operator used is =, we call it an EQUIJOIN (^) In the result of an EQUIJOIN we always have one or more pairs of attributes (whose names need not be identical)) that have identical values in every tuple.
(^) The standard definition of natural join requires that the two join attributes, or each pair of corresponding join attributes, have the same name in both relations (^) If this is not the case, a renaming operation is applied first. Operator for NATURAL JOIN is * R * S joins R and S with equality tests on all common attributes, then removes duplicate attributes