Relational Algebra
Unary Operations
Projection:
Given a list of column names and a relation R, we extract columns from the relation
Subset of columns
SQL
SELECT DISTINCT col1, col2
FROM r
Selection:
Unary operator
Filter to select rows of a relation where a condition is satisfied
SQL
SELECT DISTINCT *
FROM r
WHERE col=‘val’
Rename:
Does not change the instance, only the schema
Binary Operations
Cartesian Product X
Join: variety of operations that connect two relations
RxS concatenates every tuple in R with every tuple in S
SQL
Join
Natural Join
Union U
If two relations have the same structure, they are union-compatible and we can perform set operations
Difference
Returns items not in two tables