Take the same relational database tables as before:
RESTAURANT(RT_ID, NAME, TYPE, LOCATION)
PROXIMITY(RT1_ID, RT2_ID, DISTANCE)
USER(U_ID, NAME, EMAIL)
REVIEW(U_ID, RT_ID, RT_DATE, RATING, COMMENT)
Find the names of the reviewers who reviewed all the restaurants in Earlsfield.
one has to implement a “double not exists” query
In this case that means “find the name of any reviewer for whom there is no Earlsfield restaurant not reviewed by that reviewer”:
WHERE NOT EXISTS (
WHERE LOCATION=’Earlsfield’ AND
NOT EXISTS (
WHERE REVIEW.U_ID = USER.U_ID AND
REVIEW.RT_ID = RESTAURANT.RT_ID))
At least, I hope so! I am finding this all quite heavy going – and have ordered a book – SQL and Relational Theory: How to Write Accurate SQL Code – in the hope that it will help makes things clearer. Any other recommendations gratefully received.
Update: It does work, amazingly enough.
- Relational algebra problem (cartesianproduct.wordpress.com)
- Microsoft Researchers: NoSQL Needs Standardization (pcworld.com)
- NoSQL, NewSQL highly scalable databases (nextbigfuture.com)