GATE CS 2006 · SQL Queries

MCQ · 1 mark · Problem DBMS-SQL-0128

Consider the relation enrolled (student, course) in which student, course) is the primary key, and the relation paid (student, amount) where student is the primary key . Assume no null values and no foreign keys or integrity constraints. Given the following four queries:Query 1: Select from enrolled where student in (select student form paid)Query 2: Select student from paid where student in (select student from enrolled)Query 3: Select E. student from enrolled E, paid P where E. student= P studentQuery 4: Select student from paid where exists (select*from enrolled where enrolled student=paid.student)Which one of the following statements is correct?
  1. A
    All queries return identical row sets for any database
  2. B
    Query 2 and Query 4 return identical row sets for all databases but there exist database for which Query 1 and Query 2 retrun different row sets
  3. C
    There exist databases for which Query 3 returns strictly fewer rows than Query 2
  4. D
    There exist databases for which Query 4 will encounter an intergrity violation at runtime

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solutionOfficial GATE Answer Key: Option B.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/1846/gate2006-68

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com