Cartesian product operation in relational algebra, binary operations in relational model, cross join operation in relational algebra, Binary cartesian product operation to perform cross join in relational algebra
Cartesian Product (X) in Relational Algebra
Operation

CARTESIAN
PRODUCT (Cross Join)


Type of operation

Binary


Syntax

R1 X R2
Here, R1 and R2 can
be any one as follows;


Function

Produces a
relation that has the attributes of R1 and R2 and includes as
tuples all possible combinations of tuples from R1 and R2.
If R1(A1, A2, …,
An) is joined with R2(B1, B2, …, Bn) then it produces a new temporary
relation R(A1, A2, …, An, B1, B2, …, Bn) and every tuple (record) of R1 is
combined with every tuple of R2. For example, if R1 has 5 records and R2 has
5 records then R(A1, A2, …, An, B1, B2, …, Bn) will have 25 records.


Example 1

RA: σ_{age>15}
(student X sub_regd)
SQL: SELECT
* FROM student, sub_regd WHERE age>15;
Result: Joins the two
relations student and sub_regd and returns all students with age greater than
15.


Example 2

RA: Π _{regno,
name, subject} (σ_{age>15}
(student X sub_regd))
SQL: SELECT
regno, name, subject FROM student, sub_regd WHERE age>15;
Result: Produces a new
temporary relation with regno, name and subject attributes of all students
whose age is greater than 15 by joining student with sub_regd table.

**************
Go to Relational Algebra Operations page
No comments:
Post a Comment