Set Operations
Intersection and cross-product special cases of join.
Union (Distinct) and Except similar; we’ll do union.
Sorting based approach to union:
- Sort both relations (on combination of all attributes).
- Scan sorted relations and merge them.
Hash-based approach to union:
- Partition R and S using hash function h.
- For each S-partition, build in-memory hash table (using h2), scan corresponding R-partition and add tuples to table while discarding duplicates.