Consider the following three relations in a relational database.
Which of the following relational algebra expressions return the set of who own all the brands?
View worked solution
Answer: A;B
To find the set of employees () who own all the brands, we can analyze each option:
- Option A: The division operator () is specifically designed for "all" queries. Dividing the active ownership pairs by the set of all brands yields the s associated with every in . Thus, Option A is correct.
- Option B:
This is the standard double-negation formulation of division:
- represents all possible combinations of existing owners and all brands.
- Subtracting gives the pairs of that are missing (i.e., brands that an owner does not own).
- Projecting this on gives the set of employees who are missing at least one brand.
- Subtracting this set from all active owners leaves only those employees who do not miss any brand (i.e., they own all brands).
- Option C: This divides by (brands owned by at least one person) instead of (all existing brands). If some brand is not owned by anyone, this expression fails to check for it. Thus, Option C is incorrect.
- Option D: The cartesian product creates artificial pairs of every owner with every owned brand, losing the actual ownership information from the relation. Thus, Option D is incorrect.
Free practice · Your answers on this page are not saved.
