edited by
5,293 views
30 30 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

3 Answers

Best answer
29 29 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 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 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:
Position:
Show:

Related questions

6 6 votes
3 answers 3 answers
2.8k
2.8k views
Misbah Ghaya asked Nov 5, 2015
2,817 views
Consider a sequence of numbers $\large (\epsilon _{n}: n= 1, 2,...)$, such that $\epsilon _{1}=10$ and$\large \epsilon _{n+1}=\dfrac{20\epsilon _{n}}{20+\epsilon _{n}}$fo...
34 34 votes
4 answers 4 answers
5.6k
5.6k views
Misbah Ghaya asked Nov 8, 2015
5,649 views
Suppose $n$ processors are connected in a linear array as shown below. Each processor has a number. The processors need to exchange numbers so that the numbers eventually...
19 19 votes
6 answers 6 answers
4.5k
4.5k views
Misbah Ghaya asked Nov 8, 2015
4,513 views
Let $S$ be a set of numbers. For $x \in S$, the rank of $x$ is the number of elements in $S$ that are less than or equal to $x$. The procedure $\textsf{Select}(S, r)$ tak...
15 15 votes
2 answers 2 answers
2.8k
2.8k views
Misbah Ghaya asked Nov 8, 2015
2,756 views
In a connected weighted graph with $n$ vertices, all the edges have distinct positive integer weights. Then, the maximum number of minimum weight spanning trees in the gr...