Core Operations
| Operation | Notation | Meaning | SQL Equivalent |
| Union | A ∪ B | Elements in A or B (or both) | UNION / UNION ALL |
| Intersection | A ∩ B | Elements in both A and B | INNER JOIN / INTERSECT |
| Difference | A − B | Elements in A but not B | LEFT JOIN WHERE B IS NULL / EXCEPT |
| Complement | A' or Aᶜ | Elements not in A | NOT IN (subquery) |
| Symmetric Diff | A △ B | In A or B but not both | (A − B) ∪ (B − A) |
Set Relationships
| Relation | Notation | Meaning |
| Subset | A ⊆ B | Every element of A is in B |
| Proper Subset | A ⊂ B | A ⊆ B and A ≠ B |
| Superset | A ⊇ B | A contains all elements of B |
| Disjoint | A ∩ B = ∅ | No elements in common |
| Equal | A = B | A ⊆ B and B ⊆ A |
Cardinality Rules
| Formula | Description |
| |A ∪ B| = |A| + |B| − |A ∩ B| | Inclusion-Exclusion (2 sets) |
| |A ∪ B ∪ C| = |A|+|B|+|C| − |A∩B|−|B∩C|−|A∩C| + |A∩B∩C| | Inclusion-Exclusion (3 sets) |
| |A × B| = |A| × |B| | Cartesian product cardinality |
| |P(A)| = 2^|A| | Power set — all subsets of A |
Common Sets
| Symbol | Set | Examples |
| ℕ | Natural numbers | {1, 2, 3, ...} or {0, 1, 2, ...} |
| ℤ | Integers | {..., −2, −1, 0, 1, 2, ...} |
| ℚ | Rational numbers | p/q where p,q ∈ ℤ, q ≠ 0 |
| ℝ | Real numbers | All points on number line |
| ∅ | Empty set | Set with no elements — |∅| = 0 |
Pro Tip: Every SQL JOIN is a set operation: INNER JOIN = intersection, LEFT JOIN = A ∪ (A ∩ B), FULL OUTER JOIN = union. Understanding sets makes SQL intuitive.