Relational algebra and union
Consider a database consisting of the relations, where the primary key of each relation is bolded.
sailors ( **sid** , sname, rating, age)
boats ( **bid** , bname, color)
reserved ( **sid** , bid, date)
Find all sailor id's of sailors who have a rating of at least 8 or reserved boat 103.
Answer given is:
$π_{\mbox{sid}}\left [σ_{\mbox{rating} \geq 8} (S) \right ] \cup π_{\mbox{sid}} \left [ σ_{\mbox{bid}=103} (R) \right ]$
Why can we use a union in the solution? The selection of all sailors with a rating of at least 8 would return rows with all 4 attributes but the projection of sailors who rented boat 103 would only return the sid, right? I thought the two sets had to have the same arity.
When you project you just get the sid's. So you are taking the union of two sets of sid's.