How to Write Database Queries with Pilog