A relational schema for a train reservation database is given: Passenger(pid,pname,age) with rows (0,Sachin,65),(1,Rahul,66),(2,Sourav,67),(3,Anil,69); Reservation(pid,class,tid) with rows (0,AC,8200),(1,AC,8201),(2,SC,8201),(5,AC,8203),(1,SC,8204),(3,AC,8202). What pids are returned by: SELECT pid FROM Reservation WHERE class='AC' AND EXISTS (SELECT * FROM Passenger WHERE age>65 AND Passenger.pid=Reservation.pid)?
- A1, 0
- B1, 2
- 1, 3
- D1, 5
Explanation
AC-class Reservation rows: pid 0,1,5,3. Checking EXISTS(Passenger with matching pid AND age>65): pid0→age65, not >65, excluded. pid1→age66>65, included. pid5→no Passenger row exists, excluded. pid3→age69>65, included. Result: pids 1 and 3.
Source: GATE CS 2010 (2010)
This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.