The GATE Grind

GATE 2022 CS – Question 25

Databases · Relational Model: Relational Algebra, Tuple Calculus, SQL · 1 mark · Multiple select

Consider the following three relations in a relational database.
$Employee(\underline{eId}, Name)$, $Brand(\underline{bId}, bName)$, $Own(\underline{eId}, \underline{bId})$
Which of the following relational algebra expressions return the set of eIds who own all the brands?

  1. $\Pi_{eId}(\Pi_{eId,bId}(Own)/\Pi_{bId}(Brand))$
  2. $\Pi_{eId}(Own)-\Pi_{eId}((\Pi_{eId}(Own)\times\Pi_{bId}(Brand))-\Pi_{eId,bId}(Own))$
  3. $\Pi_{eId}(\Pi_{eId,bId}(Own)/\Pi_{bId}(Own))$
  4. $\Pi_{eId}((\Pi_{eId}(Own)\times\Pi_{bId}(Own))/\Pi_{bId}(Brand))$

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) $\Pi_{eId}(\Pi_{eId,bId}(Own)/\Pi_{bId}(Brand))$; (B) $\Pi_{eId}(Own)-\Pi_{eId}((\Pi_{eId}(Own)\times\Pi_{bId}(Brand))-\Pi_{eId,bId}(Own))$

Explanation

A is the division operator applied to the pairs and the brand list. B is the classical expansion of division: all employees minus those missing some (employee, brand) pair. C divides by brands that are owned, not all brands. D is ill-formed.