- Learning PostgreSQL 11
- Salahaldin Juba Andrey Volkov
- 91字
- 2021-07-02 13:11:39
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