318 views

Plz explain both queries!

retagged | 318 views
I think both queries won't work

ans given is Q1

Q1 : Assuming CSE branch student exist in the database table Student.

A tuple $t_1$ from Student table will be included in the result of Q1, when the corresponding inner query result is empty.

• if $t_1$.$\text{rank}$ is less than the all CSE student ranks,then only inner query results becomes empty.

Q2:

If CSE dept ranks are = $\left \{ 4,5,6,7 \right \}$

A tuple $t_1$ from Student table will be included in the result of Q2, when $t_1$.$\text{rank}$ is less than any one of $\left \{ 4,5,6,7 \right \}$. Obviously CSE topper will not be in the result of Q2

this means Q1 is wrong??
I think wrong ! What you say ?
in question they are asking anyone...but here we are getting all...I selected none but they gave q1 as ans thats why I asked here
what is wrong in my comment above ? for Q2 ?

This is basically a gate question that has been asked previously but relation names and scenario has been changed. And Q1 is correct. @Arjun sir has explained that question brilliantly. You could refer that.

http://gateoverflow.in/1259/gate2007-61

its correct but in ANY when inner query returns empty ...then result will be false thats why I think Q2 is also incorrect

They tried to copy this question with a little modification and failed horribly :p

http://gateoverflow.in/1259/gate2007-61

Q2 is definately wrong bcoz it will give even that person which has rank less than even one individual of CS, but we want only those person who have rank smaller than all individuals of CS.

Q1 is the answer. Remember here we want persons whose rank is smaller than everyone in CS.

@rahul you could say ..our interpretation for "anyone" was wrong in the particular QS. Thanks for the QS link

anyone here refers = everyone in the CSE dept. right ? @rahul ?
It don't think they have failed in changing this question. I find this questions correct and Q1 as the only answer.
@dbashish, yes.
I will say again go the link. There one comment is done by arjun sir, really an excellent one, where he has used a set and explained what anyone means. Read all comments.
Yes correct. I said so seeing the discussions going on here previously. Sorry!!
@habibkhan can you tell me this
why are you mentioning my name here??..i hadn't commented or answered here....

are you asking me to verify this???
see, neither "s2.rank<=s1.rank" nor "s2.rank<s1.rank" will work...

in case of "s2.rank<=s1.rank"...s1 will be selected only if it is less than everyone...moreover there is one more problem in this query, 'what if s1 is from CSE department, than he will never get selected because there will come a point where comparison s1.rank<=s1.rank will be done and  therefore notexist will contain some tupple and s1 will not be selected...

in case of "s2.rank<s1.rank"...s1 will not be selected  if it is greater than anyone in cse(or we can say s1 will be selected only if it less than or equal to everyone)...