The Magic of SQL: The Cups and Balls Trick