![]() |
VOOZH | about |
Prerequisite β Relational Algebra
We already are aware of the fact that relations are nothing but a set of tuples, and here we will have 2 sets of tuples.
On applying CARTESIAN PRODUCT on two relations that is on two sets of tuples, it will take every tuple one by one from the left set(relation) and will pair it up with all the tuples in the right set(relation).
So, the CROSS PRODUCT of two relation A(R1, R2, R3, β¦, Rp) with degree p, and B(S1, S2, S3, β¦, Sn) with degree n, is a relation C(R1, R2, R3, β¦, Rp, S1, S2, S3, β¦, Sn) with degree p + n attributes.
CROSS PRODUCT is a binary set operation means, at a time we can apply the operation on two relations. But the two relations on which we are performing the operations do not have the same type of tuples, which means Union compatibility (or Type compatibility) of the two relations is not necessary.
Notation:
A β Swhere A and S are the relations,
the symbol βββ is used to denote the CROSS PRODUCT operator.
Example:
Consider two relations STUDENT(SNO, FNAME, LNAME) and DETAIL(ROLLNO, AGE) below:
| SNO | FNAME | LNAME |
|---|---|---|
| 1 | Albert | Smith |
| 2 | Pearl | Weber |
| ROLLNO | AGE |
|---|---|
| 5 | 18 |
| 9 | 21 |
On applying CROSS PRODUCT on STUDENT and DETAIL,
STUDENT β DETAILSwe get:
SNO | FNAME | LNAME | ROLLNO | AGE |
|---|---|---|---|---|
1 | Albert | Smith | 5 | 18 |
1 | Albert | Smith | 9 | 21 |
2 | Pearl | Weber | 5 | 18 |
2 | Pearl | Weber | 9 | 21 |
We can observe that the number of tuples in STUDENT relation is 2, and the number of tuples in DETAIL is 2. So the number of tuples in the resulting relation on performing CROSS PRODUCT is 2*2 = 4.
Important points on CARTESIAN PRODUCT(CROSS PRODUCT) Operation:
Cardinality = m*nDegree = p+nΟ A=D (A β B)The above query gives meaningful results. And this combination of Select and Cross Product operation is so popular that JOIN operation is inspired by this combination.