Set Operations in Relational Algebra
Context: FIT2094_MOC · union, intersect, difference on relations · require union-compatible operands · the FIT1058 set operations applied to data
Quick Revision
- 🎯 Objective: set ops on relation bodies ➔ union , intersect , difference .
- 📦 Core Components: require union-compatible operands (same arity, compatible domains).
- ⚡ Key Constraint: difference is not symmetric (); duplicates auto-collapse.

📝 Core
1. The Operations
- Union ➔ = tuples in either (duplicates once).
- Intersection ➔ = tuples in both.
- Difference ➔ = tuples in not .
2. Union-Compatibility
- Same arity ➔ same number of attributes.
- Compatible domains ➔ positionally matching domains.
- Mandatory ➔ else the result isn’t a well-formed relation.
3. Symmetry
- Symmetric ➔ union, intersection commute.
- Asymmetric ➔ difference: .
Key identities:
⚖️ Core Decision Matrix
| Operation | Symbol | Symmetric? | Result |
|---|---|---|---|
| union | yes | either | |
| intersection | yes | both | |
| difference | no | in A not B | |
| precondition | — | — | union-compatible |
When It Flips: these are exactly the FIT1058 set operations on the tuple sets — inclusion–exclusion and De Morgan carry over, with union-compatibility as the new precondition. Closure holds, so set ops compose with σ/π and joins. Unlike joins (different schemas), set ops need identical schemas.
📊 Exam Execution Trace
Manual Execution Trace
STOREA, STOREB:
| Step / State | Op | Result |
|---|---|---|
| 0 (Init) | — | — |
| 1 | ||
| 2 | ||
| 3 |
⚠️ Common Mistakes
- 💡 Union-compatibility required ➔ same arity + positionally compatible domains (both
(product_id, product_name)); difference is directional.
🧠 Active Recall
Define union, intersection, and difference on relations, and the union-compatibility requirement.
- Hint: Set ops + compatibility.
Answer
- Short answer: = either, = both, = in A not B; operands must be union-compatible (same arity, compatible domains).
- Why: Well-formed ➔ compatibility ensures the result is a valid relation.
Which set operation is not symmetric, and how do these relate to FIT1058 set theory?
- Hint: Difference directional.
Answer
- Short answer: Difference: ; union/intersection commute.
- Why: Tuple sets ➔ these are FIT1058 set operations on relation bodies plus union-compatibility.