edited by
3,201 views
27 votes
27 votes

In a relational database there are three relations:

  • $Customers = C\textsf{(CName)}$,
  • $Shops = S \textsf{(SName)}$,
  • $Buys = B\textsf{(CName, SName)}$.

Which of the following relational algebra expressions returns the names of shops that have no customers at all? [Here $\Pi$ is the projection operator.]

  1. $\Pi _{\textsf{SName}}B$
  2. $S - B$
  3. $S - \Pi _{\textsf{SName}}B$
  4. $S - \Pi _{\textsf{SName}}((C \times S) - B)$
  5. None of the above
edited by

3 Answers

Best answer
28 votes
28 votes

Answer will be (C)

It subtract  shop names to those shop  which sells something.

So as a result we are getting shops which have no customer.

edited by
12 votes
12 votes

c)                                               S                            −                   ΠSNameB
                                                  ↑                                                      
 
since it has only one attribute no need of projection       it will project all the shop name which has at least                          it will project all the shop name                                         one customer

s1                                                                                                       c1   s1 
s2                                                                                                       c2   s2
s3
s4      

{s1,s2,s3,s4} - {s1,s2} = {s3,s4}          

9 votes
9 votes
  1. $\Pi$SNameB  = shops name from which atleast one customer buys.
  2. S−B  =  not Subtraction compatible .
  3. S−$\Pi$SNameBS  = Shops from which no customer buy.
  4. S−$\Pi$SName((C×S)−B)  = shops name from which every customer buy.
Answer:

Related questions

15 votes
15 votes
2 answers
4