Question: Write an interpreter that uses relational database operations to evaluate the queries in a Datalog Program. For this project, use only the schemes and facts

Write an interpreter that uses relational database operations to evaluate the queries in a Datalog Program. For this project, use only the schemes and facts to evaluate the queries. (The evaluation of rules will be added in the next project.)
Example Input
Schemes: SK(A,B) Facts: SK('a','c'). SK('b','c'). SK('b','b'). SK('b','c'). Rules: Queries: SK(X,'c')? SK('b','c')? SK(X,X)? SK(X,Y)? SK('c','c')?
Example Output
SK(X,'c')? Yes(2) X='a' X='b' SK('b','c')? Yes(1) SK(X,X)? Yes(1) X='b' SK(X,Y)? Yes(3) X='a', Y='c' X='b', Y='b' X='b', Y='c' SK('c','c')? No
The Database Classes
The solution for this project has two main parts, (1) a simple relational database and (2) an interpreter that uses the database to evaluate queries.
A relational database is a collection of relations. A relation has a name, a header, and a set of tuples. A headeris a list of attribute names. A tuple is a list of attribute values. Relations are used as operands in relational operations such as select, project, and rename.
In this project a Datalog program is represented by a database. Each scheme in the program defines a relation in the database. Each fact in the program defines a tuple in a relation.
Write classes that implement a simple relational database. Your design must include at least the following classes: Database, Relation, Header, and Tuple. Provide functions in the Relation class for each of the relational operations (select, project, and rename). Each of these functions operates on an existing relation and returns a new Relation (the result of the operation).
The Relation class must use a set data type to hold the tuples in the relation.
Test your database classes before combining them with the query interpreter described in the next section.
Decouple the database classes from the Datalog classes. For example, don't have Tuples that contain Parameters.
Datalog Program Evaluation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!