This is a two-part assignment (you will have one week for each part) in which you will implement a simple database system and perform some sample queries on your database.
In this part of the assignment you will implement an ADT for relations, and build a sample database using your ADT. The data for the relations in the database is located in /u/cs173/pub/assign1 and consists of three separate relations stored in the following text files:
You are to build an in-memory database containing the information in these files. For each relation you should implement an appropriate index structure.
Although all tuples in a relation have the same number of attributes, tuples from different relations may not have the same number of attributes.
For purposes of simplicity, you may represent all attributes in all relations as a character string of length 20.
Programming in C++, you must implement operations to
A predicate is simply a triple consisting of
This part of the assignment is due at the start of class on Tuesday, Jan 26.
In this part of the assignment you will augment your implementation of relations from Part I to incorporate additional operations (projection and join), and in addition, implement a simple query language to access your database.
The new operations are
The format of the query language has been designed to be sufficiently powerful to access the database, while remaining very simple in structure.
Every relation in the input language will be given a name that is a single letter. Every command is also a single letter.
The commands are:
c a 4 filenameThis command creates a new relation "a" with 4 attributes (again, all attributes are 20 character strings), and reads the data for the relation from the (optional) file specified.
o aThis command will print relation "a" created above.
p a 2 3 4 bThis command will project relation "a" on 2 attributes (attribute numbers 3 and 4 in relation "a") producing relation "b".
j a b cThis command joins all attributes of relations "a" and "b" producing relation "c".
s a 1 = 2 bThis command selects those tuples from relation "a" where attribute 1 = attribute 2, and produces a new relation "b" containing those tuples.
s a 1 != 'SGI' bThis command selects those tuples from relation "a" where attribute 1 != 'SGI', and produces a new relation "b" containing those tuples.
The operators allowed in the select command can be any of the comparison operators supported by your implementation of predicates.
d a 1 = 3This command deletes those tuples in relation "a" where attribute 1 = attribute 3.
As with the select command, the second operand of the predicate may be a string, and all of the comparison operations are supported.
The input to your program is a set of commands that perform some interesting queries on the database.
As a demonstration of your program, write a command language program to perform the following query: find the names of all investors that own stock in Silicon Graphics Inc (indirectly) through a mutual fund.
To illustrate the full functionality of your program, you should also show the results of other queries of your own choosing.
This part of the assignment is due at the start of class on Tuesday, Feb 2rd.