Question
Consider the following three relations in a relational database.
Which of the following relational algebra expressions return the set of eIds who own all the brands?
Official answer and solution
- Official answer
- A and B
- From
- Official GATE 2022 answer key
Solution
Express the universal quantification condition 'owns all brands' using relational algebra division and its set-difference decomposition.
To find all eId who own all brands in relation Brand:
- Expression (A) computes . Relational division returns the set of all -values that are associated in with every -value present in . Projecting
eIdyields precisely the employees who own all brands. Thus (A) is correct. - Expression (B) uses the fundamental definition of division using projection, cartesian product, and difference:
- forms all possible pairs of
(eId, brand)for each employee who owns at least one brand. - Subtracting yields the pairs
(eId, brand)representing brands that an employee does NOT own. - Projecting on
eIdgives all employees who are missing at least one brand. - Subtracting this set from leaves only those employees who own all brands. Thus (B) is correct.
- forms all possible pairs of
- Expressions (C) and (D) divide by , which only considers brands currently owned by someone rather than all brands defined in the
Brandrelation.
Options (A), (B)
Dividing by instead of , missing brands that are not yet owned by any employee.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2022 Computer Science and Information Technology (CS)
- Question
- 25 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.