Cross Product (Cartesian Product)

Tuple Level | Schema Level

Syntax:

Written Syntax: RelationA X Relation B Arcade Syntax: RelationA X RelationB

Operation Definition

This binary operation results in a relation that contains tuples where every tuple of B is appended to each tuple of A (think of distribution). Since relations are sets, the result only has unique tuple. This operation requires:

  1. 1) A – a relation
  2. 2) B – a relation

Usefulness:

This is useful if need to compare values between two relations (such as in a select) and you need the other tuple appended so you can perform an inter-tuple check. It is also useful for generating permutations.

Example:

Baz (Orginal)

A B C
1 2 3
5 6 7

Bam (Orginal)

D E
20 30
53 62
11 10

Baz X Bam

A B C D E
1 2 3 20 30
1 2 3 53 62
1 2 3 11 10
5 6 7 20 30
5 6 7 53 62
5 6 7 11 10