I have a question regarding the resulting attributes in the cross product of two relations in relational algebra…
Generally, the cross product will result in a relation whose attributes is the sum of all the attributes, So number of attributes in R1 x R2
will be attributes in R1 + R2
, so R1(a, b, c) x R2(d, e, f)
→ R(a, b, c, d ,e ,f)
…
But, what happens if R1
and R2
have common attributes (attributes of the same name)? since a relation can not have duplicate attributes… so what would happen in the case R1(a, b, c) X R2(a, e, f)
? thanks…
Best Answer
To express that relation in algebraic notation you actually need to alias the attribute.
The Cartesian product, by design, does not recognize common attribute names, so much like a single operation doesn't work in a self relation scenario, it's necessary to perform a rename within the notation.
The self join example:
Using rename:
For instance:
The Cartesian product can be expressed using relational algebra in the same way:
So then with rename: