Employee (eid, eName), Comp(cid, cName), Own(eid, cid). Which of the following…

2025

Employee (eid, eName), Comp(cid, cName), Own(eid, cid). Which of the following relational algebra expression return the set of eids who own all brands:

(1) πeid​(πeid,cid​(Own)/πcid​(Comp))

(2) πeid​(πeid​(Own)×πcid​(Comp))

(3) πeid​(πeid,cid​(Own)×πcid​(Comp))

(4) πeid​(πeid​(Own)×(πcid,cName​(Own)/πcid(Comp)))

  1. A.

    1

  2. B.

    2

  3. C.

    3

  4. D.

    4

Attempted by 167 students.

Show answer & explanation

Correct answer: A

Key idea: use the division operator to enforce the "for every company id" requirement.

  • Compute the set of all company ids: π cid(Comp).

  • Apply division: π eid,cid(Own) ÷ π cid(Comp). The division returns those employee ids for which, for every cid in π cid(Comp), the pair (eid,cid) appears in Own.

  • Project the employee ids: π eid( ... ) to get the final set of eids who own all brands.

Why the other expressions fail:

  • π eid(π eid(Own) × π cid(Comp))

    — The cross product pairs each employee id that appears in Own with every company id, so projecting eid simply returns all employees who appear in Own (those who own at least one brand). It does not check that a single employee actually owns every company id.

  • π eid(π eid,cid(Own) × π cid(Comp))

    — Crossing (eid,cid) pairs with all company ids again does not enforce per-employee coverage of all cids; projection of eid yields employees present in Own regardless of whether they own every company id.

  • π eid(π eid(Own) × (π cid,cName(Own) ÷ π cid(Comp)))

    — This expression is problematic: Own has attributes (eid,cid) and does not contain cName, so π cid,cName(Own) is invalid. Even ignoring that, dividing and then crossing with π eid(Own) does not ensure that each listed employee actually has tuples for every company id; it does not properly implement the universal condition per employee.

Conclusion: The expression that applies division of Own (projected to eid,cid) by the set of all company ids (π cid(Comp)), and then projects eid, correctly returns exactly the employees who own every brand.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor