A exercise in SQL, bringing a new appreciation for the magic of ActiveRecord