Nested Queries with Correlation
EXISTS is another set comparison operator, like IN.
If UNIQUE is used, and * is replaced by R.bid, finds sailors with at most one reservation for boat #103. (UNIQUE checks for duplicate tuples; * denotes all attributes. Why do we have to replace * by R.bid?)
Illustrates why, in general, subquery must be re-computed for each Sailors tuple.
WHERE R.bid=103 AND S.sid=R.sid)
Find names of sailors who’ve reserved boat #103: