- Learning PostgreSQL 10(Second Edition)
- Salahaldin Juba Andrey Volkov
- 90字
- 2021-07-02 22:42:04
The set theory operations
The set theory operations are union, intersection, and minus (difference). Intersection is not a primitive relational algebra operator, because it can be written using the union and difference operators:
A∩B = ((A∪B)-(A-B))-(B-A)
The intersection and union are commutative:
A∩B=B∩A
A∪B=B∪A
For example, the query, give me all the customer IDs where the customer does not have a service assigned to him, could be written as follows:
πcustomer_id customer-πcustomer_id customer_service