Relational Algebra (cont)
All RA operators return a result of type relation.
For convenience, we can name a result and use it later.
E.g. database R1(x,y), R2(y,z),
Tmp1(x,y) = Sel[x>5]R1
Tmp2(y,z) = Sel[z=3]R2
Tmp3(x,y,z) = Tmp1 Join Tmp2
Res(x,z) = Proj[x,z] Tmp3
Res(x,z) = Proj[x,z]((Sel[x>5]R1) Join (Sel[z=3]R2))
Tmp1(x,y,z) = R1 Join R2
Tmp2(x,y,z) = Sel[x>5 & z=3] Tmp1
Res(x,z) = Proj[x,z]Tmp2
|
Each "intermediate result" has a well-defined schema.
|