This preview shows page 1. Sign up to view the full content.
Unformatted text preview: n 2 (8 points) Based on the donations relation defined above, determine whether each o f the fo llowing four pairs of SQL statements is equivalent. If the pair is equivalent, just say yes and no explanat ion is needed. If you do not think the pair is equivalent, construct an instance o f the donations relat ion to illustrate the difference between the pair of statements. a) select distinct recipientName fro m donatio ns A where not exists (select B.donorOrganizat ion fro m donations B where recipientName = "Campbell” and A.donorOrganizat ion ≠ B.donorOrganizat ion) vs select distinct recipientName fro m donations A where not exists ( (select donorOrganizat ion fro m donatio ns where recipientName = "Campbell" ) except (select donorOrganizat ion fro m donatio ns B where B.recipientName = A.recipientName)) (3 points) No. Consider the instance: recipientName donorOrganization … John A John B Campbell A Campbell B Top query returns empty, while the bottom query returns John and Campbell. b) (select dist inct recipientName fro m donations where amount ≥ 500) union (select dist inc...
View Full Document
This document was uploaded on 03/18/2014 for the course CPSC 304 at University of British Columbia.
- Fall '11
- Relational Database