CSc 4340/6340, Introduction to Compilers
Spring 2012
PROJECT (DatalogQ) - DBEngine
Before the user can start using the interpreters, they must create a database against which they will submit queries. The database consists of several text files all stored within a directory. The directory is named after the database name. For example, to create a database identified with the name db1 and containing two tables:
	student(sid:integer,sname:varchar,phone:varchar,gpa:decimal)
	skills(sid:integer,language:varchar)
a directory called db1 should be created along with the following three files (one for the catalog description and the remaining two for the data for the two tables):
catalog.dat
STUDENT.dat
SKILLS.dat
The file names are case sensitive and should strictly follow the convention used, i.e. catalog.dat should be all lower case and the data files should be named after their relation name in upper case followed by the file suffix, .dat, in lower case. The catalog.dat file contains the number of relations in the first line followed by the descriptions of each relation. The description of each relation begins with the name of the relation in a separate line followed by the number of attributes in a separate line followed by attribute descriptions. Each attribute description includes the name of the attribute in a separate line followed by the data type (VARCHAR, INTEGER, or DECIMAL) in a separate line. All names and data types are in upper case. There should be no leading or trailing white space in any of the lines. The catalog.dat file for database db1 is shown below:
2
STUDENT
4
SID
INTEGER
SNAME
VARCHAR
PHONE
VARCHAR
GPA
DECIMAL
SKILLS
2
SID
INTEGER
LANGUAGE
VARCHAR
The db1 directory must include one data file for each relation. In the case of db1, they should be named STUDENT.dat and SKILLS.dat. The data file for relations contains the number of tuples in the first line followed by the description of each tuple. Tuples are described by the values under each column with each vale in a separate line. For example, let the SKILLS relation have three tuples:
	(111,Java)
	(111,C++)
	(222,Java)
These tuples will be represented in the SKILLS.dat data file as follows:
3
111
Java
111
C++
222
Java
Again, there should be no leading or trailing white spaces in any of the lines. Some pre-defined databases are available along with this laboratory manual. New data may be added to existing databases as well as new databases may be created when needed.