456 views
1 votes
1 votes

Consider the following relations
Student (Sid, Sname, age)
Courses (Cid, Cname, grade)
Enroll (Sid, Cid, fees)
Which of the following SQL query finds the name of the students who
enrolled in all the courses
Q1 Select S.Sname
from Student S
where NOT EXISTS (Select C.Cid from courses C EXCEPT select
E.Cid from Enroll E where E.Sid =S.Sid)
Q2 Select S.Sname
from Student S
where NOT EXISTS (Select * from Enroll E, courses C where E.Cid =
C.Cid AND E.Sid = S.Sid)

a. Only Q1
b. Only Q2
c. Both (Q1) and (Q2)
d. None of these

1 Answer

1 votes
1 votes
Option (A).

Consider the relations:

STudent

--------------------------------------

1 sush 21

2 sush 22

3 Jaya 23

 

courses

--------------------------

11 Java

22 OS

 

Enroll

---------------------------

1 11

2 22

3 11

3 22

 

Now, query Q2 gives $\phi$ for the above relations.Q1 returns 'Jaya'. In fact, the problem with query Q2 is even if someone hasnt registered for any course, his name will be displayed.

Related questions

0 votes
0 votes
0 answers
4
`JEET asked Dec 8, 2018
286 views
#include <stdio.h int atoi(char s[]) { int i, n; n = 0; for(i = 0; s[i] >= '0' && s[i] <= '9'; ++i) n = 10*n + (s[i] - '0'); return n; } int main() { char s[] = "jitendra...