1,859 views

Consider the following three relations in a relational database.

$\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 $\textit{elds}$ who own all the brands?

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

Correct option is  A,B.

Option A is simply they have provided the division operation.

Option B:- They wrote the division operation by simply Basic Relational operator .

why not opt C ?

All the brand details are present in the Brand table. And in Own table there is information of which employee owns which brand.

And if there is a case that a particular brand is not owned by any employee then eid,bid from (own) / bid(own) will give incorrect result.

So option C) is not correct.

How can a brand exists if it's not owned by anyone? I think there should be more details to the question to remove this kind of confusion.

Option A-It will give eid which will pair with every bid of brand so this will give correct answer.

Option B-In this option first there is a cross product between eid of Own and bid of BRAND so it will give all combination of eid and bid then there is a set difference between eid,bid of Own table this will give all employees which does not own all brand.Then at last there is set difference with eid of Own,so it will give eid which pair with every bid of brand (eid which owns all brand)

Option C-it will give eid which pair with every bid of Own (not brand) so this will give wrong answer.

Option d-

Suppose there is an instance of Own(eid,bid) like this (e1,b1) (e1,b2) (e2,b1) and suppose in brand there are only two bid b1 and b2 so it should give e1 as answer but according to option d there will be cross product between eid of Own and bid of Own so after cross product it will look like this (e1,b1), (e1,b2),(e2,b1),(e2,b2) and after performing division with bid of brand it will give eid e1 and e2 as answer which is wrong.

So this is incorrect

option A and option B are correct.