### Review of Relational Algebra

• Relational Algebra

• Relational Algebra:

 is a mathematical language for manipulating sets

• Recall that a Relation is:

• is a set of tuples

Example:

 ```ssn fname lname salary dname --------- ------ -------- --------- --------------- 123456789 John Smith 20900.00 Research 333445555 Frankl Wong 50000.00 Research 999887777 Alicia Zelaya 25000.00 Administration <-- 1 tuple 987654321 Jennif Wallace 43000.00 Administration 666884444 Ramesh Narayan 38000.00 Research 453453453 Joyce English 25000.00 Research 987987987 Ahmad Jabbar 25000.00 Administration 888665555 James Borg 55000.00 Headquarters ```

• The operations in Relational Algebra

• Operations of Relational Algebra can be divided into 3 categories:

1. Set operators:

 ∪ = set union ∩ = set intersection − = set difference × = cartesian product

2. Relational database specific operators:

 σ = the selection operator π = the projection operator ⋈ = the join operator

3. Aggregate function:

 sum:     find the sum of a set of values avg:      find the average of a set of values count:  find the cardinality of a set of values        any:      find the existance of a set of values max:     find the maximum of a set of values min:     find the minumum of a set of values

• Important note:

• The result of a Relational Algebra operation is always:

 a relation (= a set of tuples)