Logic Programming
What
versus
How
 

Lessons Epilog Sierra Examples Games


This goal of this problem is to give you some experience mapping data between different representations. To get started, consider the dataset of university information shown below.

You will notice that the data is in triple representation. There is a unary predicate faculty that holds of faculty members, and each faculty member has properties captured using various attributes. The attribute faculty.rank relates a faculty member and his academic rank. The attribute faculty.affiliation relates a faculty member and his department. The attribute faculty.office relates a faculty member and his office.

We can write a query that outputs the information about faculty members using a single 4-ary relation, i.e. there is just one 4-ary predicate in the resulting dataset and no unary or binary predicates.

If we apply our query to the data above, we get the following result.

Now consider the following data.

You will notice that one of the faculty members has two departments, and one has no office. If we apply our query to this dataset, we get multiple rows in one case and no rows in the other.

In order to deal with this situation, we can replace the department and office fields with sets rather than individual items. Rewrite the query above to output results using this alternate representation. Since there are twelve faculty members, there should be twelve answers.