Question
Consider the following relational schema:
Students (rollno: integer, name: string, age: integer, cgpa: real)
Courses (courseno: integer, cname: string, credits: integer)
Enrolled (rollno: integer, courseno: integer, grade: string)
Which of the following options is/are correct SQL query/queries to retrieve the names of the students enrolled in course number (i.e., courseno) 1470?
Official answer and solution
- Official answer
- A, C and D
- From
- Official GATE 2025 answer key
Solution
Check SQL syntax and semantics for EXISTS, COUNT(*), NATURAL JOIN, and the non-existent SIZEOF keyword.
- (A) is CORRECT: Standard correlated subquery using
EXISTSto check whether the student'srollnoappears inEnrolledwithcourseno = 1470. - (B) is INCORRECT:
SIZEOFis not a valid SQL keyword/operator. - (C) is CORRECT: Standard correlated subquery checking that the count of matching enrollment rows for
S.rollnoandcourseno = 1470is greater than0. - (D) is CORRECT:
StudentsandEnrolledshare only the attributerollno, soNATURAL JOINperforms an equijoin onS.rollno = E.rollno, andWHERE E.courseno = 1470filters for students enrolled in course1470.
Options (A), (C), (D)
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2025 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 54 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.