Skip to content
Official PYQ · 2022

GATE CS 2022 Q15 — Relational Model: Relational Algebra

Explain with AI

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?

Select all correct options
View worked solution

Answer: A;B

To find the set of employees (eIdeId) who own all the brands, we can analyze each option:

  • Option A: ΠeId(ΠeId,bId(Own)/ΠbId(Brand))\Pi_{eId} \left(\Pi_{eId,bId} (Own) / \Pi_{bId} (Brand) \right) The division operator (//) is specifically designed for "all" queries. Dividing the active ownership pairs by the set of all brands yields the eIdeIds associated with every bIdbId in Brand\text{Brand}. Thus, Option A is correct.
  • Option 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) This is the standard double-negation formulation of division:
    1. (ΠeId(Own)×ΠbId(Brand))(\Pi_{eId} (Own) \times \Pi_{bId} (Brand)) represents all possible combinations of existing owners and all brands.
    2. Subtracting ΠeId,bId(Own)\Pi_{eId,bId} (Own) gives the pairs of (eId,bId)(eId, bId) that are missing (i.e., brands that an owner does not own).
    3. Projecting this on eIdeId gives the set of employees who are missing at least one brand.
    4. Subtracting this set from all active owners ΠeId(Own)\Pi_{eId}(Own) leaves only those employees who do not miss any brand (i.e., they own all brands).
    Thus, Option B is correct.
  • Option C: ΠeId(ΠeId,bId(Own)/ΠbId(Own))\Pi_{eId} \left(\Pi_{eId,bId} (Own) / \Pi_{bId} (Own) \right) This divides by ΠbId(Own)\Pi_{bId}(Own) (brands owned by at least one person) instead of ΠbId(Brand)\Pi_{bId}(Brand) (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: ΠeId((ΠeId(Own)×ΠbId(Own))/ΠbId(Brand))\Pi_{eId} \left( (\Pi_{eId}(Own) \times \Pi_{bId} (Own)) / \Pi_{bId} (Brand) \right) The cartesian product creates artificial pairs of every owner with every owned brand, losing the actual ownership information from the OwnOwn relation. Thus, Option D is incorrect.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Relational Model: Relational Algebra questions