Loading...
Loading...
Discrete Math · Axiom Academy
REAL WORLD Database Queries as Sets Discover how SQL database operations are built on set theory foundations using AND, OR, and NOT operators Databases are everywhere in the digital world—from social media to online stores. Behind the scenes, every database query uses set theory to filter and combine data. Let's explore how! This database represents a set of employees. Each employee has properties (department, salary, remote status). When we query this database, we're performing set operations ! The AND Operator (Intersection: ∩) The SQL AND operator finds records that satisfy multiple conditions simultaneously . In set theory, this is the intersection (∩) of two sets. A ∩ B = elements in BOTH A and B WHERE condition1 AND condition2 ✓ Query Results (Intersection) Only 2 employees satisfy both conditions—that's the intersection! The SQL OR operator finds records that satisfy at least one condition . In set theory, this is the union (∪) of two sets. A ∪ B = elements in A or B or both WHERE condition1 OR condition2 4 employees satisfy at least one condition—that's the union! ❌ The NOT Operator (Complement: A') The SQL NOT operator finds records that do not satisfy a condition. In set theory, this is the complement of a set. A' = all elements NOT in set A 3 employees are in the complement—they work in the office! Now let's test your understanding by writing real SQL queries. Each query will help you practice combining set operations.
This is the written version of the interactive lesson above. See the full Discrete Math course.