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.] $\Pi _{\textsf{SName}}B$ $S - B$ $S - \Pi _{\textsf{SName}}B$ $S - \Pi _{\textsf{SName}}((C \times S) - B)$ None of the above Databases tifr2013 databases relational-algebra + – Misbah Ghaya 5.3k views answer comment Share Follow Print See all 4 Comments 4 4 Comments reply Lakshman Bhaiya commented Nov 25, 2018 reply Follow flag Customers as $C$ Cname A B C D Shops as $S$ Sname $s_{1}$ $s_{2}$ $s_{3}$ Buys as $B$ Cname Sname A $s_{1}$ B $s_{2}$ C $s_{1}$ D $s_{1}$ In this example I take $s_{1}$ is the Shop name, who have at least three Customers(A,C,D) $s_{2}$ is the Shop name, who have at least one Customers(B) $s_{3}$ is the Shop name who do not have any Customers(the names of shops that have no customers at all) $(A)\Pi_{Sname}B$ Sname $s_{1}$ $s_{2}$ $(B)S-B$ It is not possible, because it is not Subtraction compatible. $(C)S-\Pi_{Sname}B$ $\Pi_{Sname}B$ Sname $s_{1}$ $s_{2}$ Now, $S-\Pi_{Sname}B$ Sname $s_{3}$ So,this is true. $(D)S-\Pi_{Sname}((C\times S)-B)$ Now, $C\times S$ Cname Sname A $s_{1}$ A $s_{2}$ A $s_{3}$ B $s_{1}$ B $s_{2}$ B $s_{3}$ C $s_{1}$ C $s_{2}$ C $s_{3}$ D $s_{1}$ D $s_{2}$ D $s_{3}$ Now,$(C\times S)-B$ Cname Sname A $s_{2}$ A $s_{3}$ B $s_{1}$ B $s_{3}$ C $s_{2}$ C $s_{3}$ D $s_{2}$ D $s_{3}$ Now,$\Pi_{Sname}((C\times S)-B)$ Sname $s_{1}$ $s_{2}$ $s_{3}$ Here clearly see $S-\Pi_{Sname}((C\times S)-B)=\phi$ So,$(C)$ is the right choice please correct me if i''m wrong. 6 6 replyShare HeadShot commented Dec 5, 2018 reply Follow flag @Lakshman Patel RJIT Well explained . Just a suggestion : In Buys B , try to satisfy ( no buys, all buys, some buys) conditions so that no option will be left. for eg. : i think your example can not catch option D ( though not needed in this question) if question were " find equivalent expression that gives name of customer that bought from all shops. ( may be i am not fully correct but think over it ) 2 2 replyShare Lakshman Bhaiya commented Dec 6, 2018 reply Follow flag @HeadShot as this question, I frame an example, if they ask, which expression is equivalent, I can frame another example. I think $(D)$ option works fine for this example. thank you for suggesting me. 2 2 replyShare Deepak Poonia commented Aug 28, 2024 reply Follow flag Detailed Video Solution, with Complete Analysis: https://youtu.be/h3pJZbed9M8?t=2835&feature=sharedAnalysis of Option D is also discussed in above video. 0 0 replyShare Please log in or register to add a comment.
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. srestha answered Nov 8, 2015 • edited Oct 15, 2018 by kenzou srestha comment Share Follow See all 7 Comments 7 7 Comments reply Show 4 previous comments srestha commented Oct 27, 2019 reply Follow flag chk it :https://gateoverflow.in/19246/tifr2010-b-33 0 0 replyShare `JEET commented Dec 4, 2019 reply Follow flag @srestha @Satbir I understand $\mathbf C$ is the correct answer. But what is fundamentally wrong with option $\mathbf A$. It doesn't contain the name of any customers, right? It only contains shop names which can be NUL as well. Can you please explain this. 0 0 replyShare Satbir commented Dec 5, 2019 reply Follow flag what is $CName$ then in $B$ ? $B$(buys) in option $A$ is a relation which denotes customer having $CName$ buys from shop named $Sname$ and in option $A$ we are simply projecting all the shop names. see the table given by Lakshman patel 0 0 replyShare Please log in or register to add a comment.
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} Umang Raman answered Nov 8, 2015 Umang Raman comment Share Follow 0 reply Please log in or register to add a comment.
9 9 votes $\Pi$SNameB = shops name from which atleast one customer buys. S−B = not Subtraction compatible . S−$\Pi$SNameBS = Shops from which no customer buy. S−$\Pi$SName((C×S)−B) = shops name from which every customer buy. Anu007 answered Nov 6, 2017 Anu007 comment Share Follow See all 2 Comments 2 2 Comments reply anchitjindal07 commented Nov 17, 2019 reply Follow flag Can u please explain Option D 1 1 replyShare Deepak Poonia commented Aug 28, 2024 reply Follow flag @anchitjindal07Detailed Video Solution, with Complete Analysis: https://youtu.be/h3pJZbed9M8?t=2835&feature=sharedAnalysis of Option D is also discussed in above video. 0 0 replyShare Please log in or register to add a comment.