CARTESIAN PRODUCT (×) Operation
CARTESIAN PRODUCT (×) Operation
(Cross Product / Cross Join)
1. What is the Cartesian Product?
The CARTESIAN PRODUCT is a binary relational algebra operation denoted by:
Unlike UNION or INTERSECTION:
-
The two relations do NOT need to be union compatible
-
It simply pairs every tuple of one relation with every tuple of the other
2. Formal Definition
Let:
Then:
Properties:
-
Degree of Q =
-
Number of tuples:
👉 Each tuple in the result is formed by concatenating one tuple from R with one tuple from S.
3. Intuitive Understanding
Think of the Cartesian Product as:
“All possible combinations of tuples from the two relations.”
If:
-
Relation R has 3 tuples
-
Relation S has 4 tuples
Then:
-
will have 12 tuples
4. Why Cartesian Product Alone Is Usually Meaningless
By itself, the Cartesian Product:
-
Produces large relations
-
Creates combinations with no real-world meaning
📌 This is why :
“The CARTESIAN PRODUCT operation applied by itself is generally meaningless.”
It becomes meaningful only when followed by a SELECT condition that links related tuples.
5. Example (EMPLOYEE and DEPENDENT)
Problem Statement:
Retrieve the names of each female employee’s dependents
Step 1: Select female employees
Step 2: Project required employee attributes
Step 3: Cartesian product with DEPENDENT
Step 4: Select matching employee–dependent tuples
Step 5: Final projection
Single In-Line Expression (Optional Exam Form)
Explanation
Step 1: Select female employees
✔ Keeps only tuples where Sex = 'F'
Step 2: Project required attributes
✔ Retains employee name and SSN only
Step 3: Apply Cartesian Product
🔴 Important observation:
-
Every female employee is paired with every dependent
-
Result includes invalid combinations
Example:
-
Jennifer Wallace is paired with all dependents, even those who are not hers
This relation is syntactically correct but semantically meaningless
Step 4: Select only matching tuples
✔ Keeps only those tuples where:
-
Employee SSN = Dependent’s Essn
This step filters out incorrect combinations
Step 5: Final projection
✔ Final meaningful result:
6. Key Teaching Insight (Very Important)
Relational algebra does not prevent meaningless results.
It is the user’s responsibility to:
-
Apply correct operations
-
Add appropriate conditions after Cartesian Product
7. Cartesian Product + Selection = JOIN
Because the pattern:
is used so often, a new operation called JOIN was introduced.
📌 JOIN is simply:
A shorthand for Cartesian Product + Selection
8. SQL Correspondence
In SQL, Cartesian Product can be produced in two ways:
Method 1: CROSS JOIN
Method 2: Missing join condition
⚠ If no WHERE clause connects the tables, SQL produces a Cartesian Product.
9. Summary Table (Exam-Friendly)
| Aspect | Cartesian Product |
|---|---|
| Symbol | × |
| Type | Binary operation |
| Union compatibility | Not required |
| Result degree | Sum of degrees |
| Result tuples | |
| Meaning by itself | Usually meaningless |
| Used with | SELECT or JOIN |
10. Summary
The Cartesian Product combines every tuple of one relation with every tuple of another relation, and is meaningful only when followed by a selection that relates the tuples.

Comments
Post a Comment