Loading…
Computer Science · Ch 9 — Structured Query Language (SQL)
The Cartesian product (also called the cross product) is a relational algebra operation that combines every row from one table with every row from another table. It is denoted by the symbol X.
Unlike the join operations you will study later, the Cartesian product does not check for matching values on common attributes. It simply pairs each row of the first relation with each row of the second relation, regardless of whether the data in those rows is related or not.
When you apply the Cartesian product to two relations, the structure and size of the resulting relation change in a predictable way:
| SNo | Name | Class | SNo | Name | Class |
|---|---|---|---|---|---|
| 1 | Aastha | 7A | 1 | Mehak | 8A |
| 2 | Mahira | 6A | 1 | Mehak | 8A |
| 3 | Mohit | 7B | 1 | Mehak | 8A |
| 4 | Sanjay | 7A | 1 | Mehak | 8A |
| 1 | Aastha | 7A | 2 | Mahira | 6A |
| 2 | Mahira | 6A | 2 | Mahira | 6A |
| 3 | Mohit | 7B | 2 | Mahira | 6A |
| 4 | Sanjay | 7A | 2 | Mahira | 6A |