The objective of this worksheet is to

  • Write algebraic expressions to solve basic Datalog queries that do not involve rules.
  • Work examples of Datalog queries by hand
  • Design the classes and interfaces needed to support the use of relational algebra to interpret Datalog programs.


  1. Create a Datalog file with at least a 3-ary relation and write queries for the relation that represent the range of queries and outputs that might occur. You need at least 4 queries minimum. Justify your answer (i.e., explain why your set of queries is representative of what may be encountered in an arbitrary Datalog input with just facts).
  2. For each query in the prior problem, write the algebraic expression to solve the query.
  3. Solve each query in the first problem by hand showing the relation created after each unary operation in the algebraic expression.
  4. Design a class to represent a relation and to represent a tuple. Include the member variables and method interface.
  5. Write pseudo-code for the select, rename, and project operations on the relation.
Back to top