SQL

Tuple Relational Calculus

Description of the data

Relational Algebra

Procedure to retrieve data

 

Selection

select * from r where theta

{ R |  r(R)  and  theta  }

{ t | t member of r and theta}

Projection

select distinct A from r

{ R.ai . . . R.aj  |  r(R) }
   with ai . . . aj  member of  A

{ t.A | t  member of r }

Union

select * from r
union
select * from s

{T | r(T) or s(T) }

{ t | t  member of r  or  t  member of s }

Minus

select * from r
minus
select * from s

{T | r(T) and not s(T) }

{ t | t  member of r  and  t  member of s }

Cartesian Product

select * from r, q

{ R,Q | r(R) and q(Q) }

{ tr tq | tr  member of r and tq  member of q  }

Join

select * from p, q where theta

{ P,Q | p(P) and q(Q) and theta}

{tptq | tp member of p and tq member of  q and theta}

Intersection      
Division