GATE CSE
First time here? Checkout the FAQ!
x
+6 votes
318 views

Plz explain both queries!

asked in Databases by Veteran (10.6k points) 5 23 53
retagged by | 318 views
I think both queries won't work

whats the answer
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

quoting from that QS comments:

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)...

Please log in or register to answer this question.

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users Oct 2017
  1. Arjun

    23462 Points

  2. Bikram

    17108 Points

  3. Habibkhan

    8560 Points

  4. srestha

    6314 Points

  5. Debashish Deka

    5458 Points

  6. jothee

    5038 Points

  7. Sachin Mittal 1

    4882 Points

  8. joshi_nitish

    4416 Points

  9. sushmita

    3996 Points

  10. Rishi yadav

    3868 Points


Recent Badges

Notable Question Sanjay Sharma
Notable Question Warrior
Notable Question sid1221
Nice Answer 2018
Good Question Arjun
Nice Question mitalitak
Great Question Arjun
Popular Question Tesla!
Nice Question makhdoom ghaya
Popular Question Sankaranarayanan P.N
27,348 questions
35,204 answers
84,249 comments
33,328 users