Skip to main content

GATE CSE 2022Databases › Relational Algebra & CalculusVerified

GATE CSE 2022 PYQ: Consider the following three relations in a relational database. Employee ( eId ‾ , Name ) , Brand ( bId ‾ ,…

Consider the following three relations in a relational database.

Employee(eId‾,Name),  Brand(bId‾,bName),  Own(eId‾,bId‾)\text{Employee} (\underline{\text{eId}},\text{Name}), \; \text{Brand}(\underline{\text{bId}},\text{bName}), \; \text{Own}(\underline{\text{eId}},\underline{\text{bId}})

Which of the following relational algebra expressions return the set of elds\textit{elds} who own all the brands?

  1. A
    ΠeId(ΠeId,bId(Own)/ΠbId(Brand)) \Pi_{eId} \left(\Pi_{eId,bId} (Own) / \Pi_{bId} (Brand) \right)
    Correct answer
  2. B
    ΠeId(Own)–ΠeId((ΠeId(Own)×ΠbId(Brand))–ΠeId,bId(Own)) \Pi_{eId} (Own) – \Pi_{eId} \left( ( \Pi_{eId} (Own) \times \Pi_{bId} (Brand)) – \Pi_{eId,bId} (Own)\right)
    Correct answer
  3. C
    ΠeId(ΠeId,bId(Own)/ΠbId(Own)) \Pi_{eId} \left(\Pi_{eId,bId} (Own) / \Pi_{bId} (Own) \right)
  4. D
    ΠeId((ΠeId(Own)×ΠbId(Own))/ΠbId(Brand)) \Pi_{eId} \left( (\Pi_{eId}(Own) \times \Pi_{bId} (Own)) / \Pi_{bId} (Brand) \right)

Answer

(A, B) Π e I d ( Π e I d , b I d ( O w n ) / Π b I d ( B r a n d ) ) \Pi_{eId} \left(\Pi_{eId,bId} (Own) / \Pi_{bId} (Brand) \right) Π e I d ​ ( Π e I d , b I d ​ ( Ow n ) / Π b I d ​ ( B r an d ) ); Π e I d ( O w n ) – Π e I d ( ( Π e I d ( O w n ) × Π b I d ( B r a n d ) ) – Π e I d , b I d ( O w n ) ) \Pi_{eId} (Own) – \Pi_{eId} \left( ( \Pi_{eId} (Own) \times \Pi_{bId} (Brand)) – \Pi_{eId,bId} (Own)\right) Π e I d ​ ( Ow n ) – Π e I d ​ ( ( Π e I d ​ ( Ow n ) × Π b I d ​ ( B r an d )) – Π e I d , b I d ​ ( Ow n ) )

Approach

Use the definition of relational division and its equivalent set-difference formulation to find employees who own every brand.

A is the direct division expression for 'own all brands'. B is a known relational-algebra equivalent of division using set difference and projection. C and D use the wrong divisor or an incorrect cross product, so they do not correctly return the required set of eIds.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.