in Databases retagged by
454 views
5 votes
5 votes

Consider the following schema:

The primary key fields are underlined, and the domain of each field is listed after the field name. Assume there are no NULL values in any column of any relation and every relation has at least one tuple. $\textsf{“Sid”}$ of Reserves is foreign key to $\textsf{Sailors.sid}.$

Assume that there is at least one sailor who has reserved a boat with bid $104$ in the reserves table.

Consider the following query :

SELECT S.sid
FROM Sailors S, Reserves R
WHERE S.rating = 10 OR R.bid = 104

What is the output of the above query?

  1. All sids of sailors who have a rating of $10$ AND have reserved boat $104.$
  2. All sids of sailors who have a rating of $10 $ OR have reserved boat $104.$
  3. All sids of sailor table
  4. Empty set.
in Databases retagged by
454 views

1 Answer

3 votes
3 votes

Since there exists a sailor who has reserved a boat with bid $104$ in the reserves table, The query will return ALL sids of sailors table because, for every tuples of sailors table ,we will have a tuple in the cross product of Sailors and Reserves tables, with $\textsf{reserves.bid = 104}.$ So, ALL said of sailor table will be in the output.

Take for example the following relation instance for sailor :

The following relation instance for reserves :

Run the query for this instance, output will be ALL sids of sailors.

edited by
Answer:

Related questions