2001
5.c. Explain Cartesian product of two relations.
Ans: The Cartesian product is a binary operation and is denoted by a cross(x). The Cartesian product of two relations A and B is written as AXB. The Cartesian product yields a new relation which has a degree (number of attributes) equal to the sum of the degrees of the two relations operated upon. The number of typles (cardinality) of the new relation is the product of the number of tuples of the two relations operated upon. The Cartesian product of two relations yields a relation with all possible combinations of the tuples of the two relations operated upon. All tuples of first relation are concatenated with all the tuples of second realtion to form the tuples of the new relation.
Eg: There are two relations as follows:
Relation 1: Student
StudentNumber StudentName Hosteler
1 Ravi Y
2 Robert N
3 Raheem Y
Relation 2: Instructor
InstructorName Subject
K.Suman Computer Science
P.Pavan Electronics
The Cartesian product of these two relations,
Student X Instructor, will yield a relation that have a degree of 5(3+2:sum of degrees of Student and Instructor) and a cardinality 6 (3 X 2: Product of cardinalities of two relations).
The resulting relation is as follows:
Student Number | Student Name | Hosteler Instructor | Subject Name |
1 | Ravi | Y K.Suman | Computer Science |
1 | Ravi | Y P.Pavan | Electronics |
2 | Robert | N K.Suman | Computer Science |
2 | Robert | N P.Pavan | Electronics |
3 | Raheem | Y K.Suman | Computer Science |
3 | Raheem | Y P.Pavan | Electronics |