All mock tests are FREE till 31 December — register to save your progress
Unit 4 · Database Management Systems Paper 2 CS · September 2022

Directions (Q31–35): Consider the relational schema of Sailors S, Reserves R and Boats B.

Table 1: Sailors

SidSnameRatingAge
22Dustin745.0
29Brutus133.0
31Lubber855.5
32Andy825.5
58Rusty1035.5
64Horatio735.5
71Zorba1016.0
74Horatio935.0
85Art325.5
95Bob363.5

Table 2: Reserves

SidBidDay
2210110/10/98
2210210/10/98
2210310/8/98
2210410/7/98
3110211/10/98
3110311/6/98
3110411/12/98
641019/5/98
641029/8/98
741039/8/98

Table 3: Boats

BidBnameColor
101Interlakeblue
102Interlakered
103Clippergreen
104Marinered

Which query computes the names of sailors who have reserved a red and a green boat?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: A. ρ(Tempred, πsid((σcolor='red' Boats) ⋈ Reserves)); ρ(Tempgreen, πsid((σcolor='green' Boats) ⋈ Reserves)); πsname((Tempred ∩ Tempgreen) ⋈ Sailors)

Explanation

Intersect the sids that reserved a red boat with those that reserved a green boat. B, C and D intersect boats instead, and no boat is both red and green, so they return nothing.

More Database Management Systems questions