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

Consider the following three relations in a relational database. Employee(eId, Name), Brand(bId, bName), Own(eId, bId) Which of the following relational algebra expressions return the set of eIds who own all the brands?  Correct Answer Π<sub>eld</sub> (<span style="">Π</span><span style=" line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em; font-size:10.5px;">eld,bld</span><span style="">​ (Own)/Π<sub>b</sub></span><span style=" line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em; font-size:10.5px;">ld</span><span style="">​ (Brand))</span>, <span style="">Π</span><span style=" line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em; font-size:10.5px;">eld</span><span style="">​ (Own) - Π</span><span style=" line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em; font-size:10.5px;">eld</span><span style="">​ ((Π</span><span style=" line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em; font-size:10.5px;">eld</span><span style="">​ (Own) × Π<sub>b</sub></span><span style=" line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em; font-size:10.5px;">ld</span><span style="">​ (Brand)) - Π</span><span style=" line-height: 0; position: relative; vertical-align: baseline; bottom: -0.25em; font-size:10.5px;">eld,bld</span><span style="">​ (Own))</span>

Concept:

  • The "Division operator" in relational algebra return all the entities that are associated with entities of different relation.

 

The result of the query in option 1:
It will display all the eId of relation "Own" which are associated with all the bId of relation "Brand".

The result of the query in option 2: 

At first, the cartesian product is performed between Own(eId) and Brand(bId). Which results in the association of all eId with all bId. 

Now, subtract the Own relation entities from the newly generated relation which contains the cartesian product. This will result in eIds that are not associated with bIds.

Subtracting these resulted eIds from the Own relation to retrieve the eIds that are associated with bId in the Brand relation, which is similar to the option 1 result.

Πeld (Πeld,bld​ (Own)/Πeld​ (Brand)) = Πeld​ (Own) - Πeld​ ((Πeld​ (Own) × Πeld​ (Brand)) - Πeld,bld​ (Own))

Related Questions

Consider the following relation schema Sailors(sid, sname, rating, age) Reserve(sid, bid, day) Boats(bid, bname, color) What is the equivalent of following relational algebra query in SQL query. πsname((σcolor= ‘red’Boats) ⨝ Reserves ⨝ Sailors)  
The question given below consists of a statement, followed by three arguments numbered I, II and III. You have to decide which of the arguments is/are ‘strong’ arguments and which is/are ‘weak’ arguments and accordingly choose your answer from the alternatives given below each question. Statement: As a trade war looms, one of Chinese President Xi Jinping’s biggest weapons could be boycotts of American brands by his country’s legion of consumers. But Xi would also be risking collateral damage at home, The China operations of all-American brands ranging from Coca-Cola Co. and McDonald’s Corp. to Walt Disney Co. are co-owned by state-backed Chinese firms.  Which among the following arguments support the above statement in the best possible manner? Arguments: I. One of Coke’s main China partners is government-backed COFCO Corp., Shanghai Disneyland is part owned by a local consortium, and McDonald’s franchisee in the country is controlled by state-backed conglomerate Citic Ltd. and private-equity firm Citic Capital Holdings.  II. Even when Chinese companies don’t have direct ownership links with U.S. brands, boycotts or other non-tariff retaliation would hit the local partners of those American companies. III. The number of big clean wins in terms of striking against the other guy (American brands) - without accidentally punching your own guy (Chinese firms) in the face - is extremely large.
What does the following query find?
(SELECT DISTINCT r.sid
FROM boats b, reserves r
WHERE b.bid = r.bid
AND b.color = 'red')
MINUS
(SELECT DISTINCT r.sid
FROM boats b, reserves r
WHERE b.bid = r.bid
AND b.color = 'green')