Skip to content
Official PYQ · 2003

GATE CS 2003 Q86 — Tuple Calculus and SQL

Explain with AI

Consider the set of relations shown below and the SQL query that follows.

Students: (Roll_number, Name, Date_of_birth)

Courses: (Course_number, Course_name, Instructor)

Grades: (Roll_number, Course_number, Grade)

Select distinct Name
from Students, Courses, Grades
where Students.Roll_number=Grades.Roll_number
	and Courses.Instructor = 'Korth'
	and Courses.Course_number = Grades.Course_number
	and Grades.Grade = 'A'

Which of the following sets is computed by the above query?

Choose one option
View worked solution

Answer: C

To understand what the SQL query computes, let us analyze its components:

  1. Joins: The FROM clause specifies three tables: Students, Courses, and Grades. The WHERE clause joins them using:
    • Students.Roll_number = Grades.Roll_number
    • Courses.Course_number = Grades.Course_number
    This combines student details with their course details and grades.
  2. Filters: The query applies two specific conditions:
    • Courses.Instructor = 'Korth' (the course must be taught by Korth)
    • Grades.Grade = 'A' (the student must have received an 'A' grade in that course)
  3. Projection: The SELECT distinct Name retrieves the unique names of students who satisfy these conditions.

Since the query simply joins the tables and filters for any matching rows (without using nested subqueries, NOT EXISTS, or aggregation with GROUP BY / HAVING COUNT), it performs an existential check. If a student has received an 'A' grade in at least one course taught by Korth, their name will appear in the result.

Therefore, the query computes: "Names of students who have got an A grade in at least one of the courses taught by Korth."

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Tuple Calculus and SQL questions