CSCI 2230-Programming Assignment 2: Database Catalogs - Prof. Vernon W. Pine, Assignments of Digital Signal Processing

A programming assignment for a database systems course, where students are required to create a database management system. The assignment covers creating catalogs to store metadata about database tables, fixed and variable length data files, and implementing commands to interact with the catalogs. Students are expected to work in groups and use the 'einstein' system.

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-9e2
koofers-user-9e2 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCI 2230-001 Programming Assignment #2
Due: 4 March Database Catalogs
Goals You will become familiar with the use of catalogs to store meta-data about database
tables. The program will use low-level access methods to read and write records of fixed length.
You must implement your solution on einstein. This program must be done in groups of two or
three students.
1. Startup On program startup, the shell command line should contain the name of a database.
If this is a new database, create a new subdirectory using that name, make that subdirectory the
current working directory, and create the two database catalogs. If this is an existing database,
change to that subdirectory and open the two catalogs. If no database name is given, display an
error message and quit.
The catalogs are two binary (fixed length record) files, the relation catalog and the attribute
catalog, using the following fixed record formats exactly:
relcat( char relname[20], int reclength, int attrcount, int reccount, int sortfield, char
format)
attrcat( int attrnum, int attroffset, int attrlength, char attrtype, char attname[20], char
relname[20])
Declare classes for each of these types. You may find it useful to create a “set all fields” member
function for each, since you’ll be writing several hard-coded records to each file.
When a database is created, both catalog files should be created, the first called “relcat” and the
second called “attrcat” (no file extensions). The relcat will initially have two entries (one for the
relcat itself and one for the attrcat), and the attrcat will have twelve entries (six for the re1cat
attributes and six for the attrcat attributes). Refer to the class handout for the data contained in
these entries.
2. Data Format Only three types of data will be our database:
integer denoted by an I in the attrcat’s attrtype field,
double denoted by a D, and
character denoted by a C and a length.
A data file may either be fixed length or variable length. For fixed length records, create a binary
file, and place the letter F in the relcat’s format field. For variable length records, create a text
file, and delimit the records with the character | , and place the letter V in the relcat’s format
field. For now, only the catalogs exist; since both are fixed length files, both will contain an F in
the format field. Later assignments will clarify the data format.
3. Commands Read commands from the standard input. Do not prompt for them, however.
Your program will be run against a test script, which may not work with prompting. Include
simple error checking - display an error message on incorrect commands. See below for
examples.
a. Show Catalogs. Command: S Display the contents of the relcat and attrcat, in neat tabular
format, with column headings and reasonable spacing.
pf2

Partial preview of the text

Download CSCI 2230-Programming Assignment 2: Database Catalogs - Prof. Vernon W. Pine and more Assignments Digital Signal Processing in PDF only on Docsity!

CSCI 2230-001 Programming Assignment

Due: 4 March Database Catalogs

Goals You will become familiar with the use of catalogs to store meta-data about database tables. The program will use low-level access methods to read and write records of fixed length. You must implement your solution on einstein. This program must be done in groups of two or three students.

1. Startup On program startup, the shell command line should contain the name of a database. If this is a new database, create a new subdirectory using that name, make that subdirectory the current working directory, and create the two database catalogs. If this is an existing database, change to that subdirectory and open the two catalogs. If no database name is given, display an error message and quit. The catalogs are two binary (fixed length record) files, the relation catalog and the attribute catalog, using the following fixed record formats exactly: relcat( char relname[20], int reclength, int attrcount, int reccount, int sortfield, char format) attrcat( int attrnum, int attroffset, int attrlength, char attrtype, char attname[20], char relname[20]) Declare classes for each of these types. You may find it useful to create a “set all fields” member function for each, since you’ll be writing several hard-coded records to each file. When a database is created, both catalog files should be created, the first called “relcat” and the second called “attrcat” (no file extensions). The relcat will initially have two entries (one for the relcat itself and one for the attrcat), and the attrcat will have twelve entries (six for the re1cat attributes and six for the attrcat attributes). Refer to the class handout for the data contained in these entries. 2. Data Format Only three types of data will be our database: integer denoted by an I in the attrcat’s attrtype field, double denoted by a D , and character denoted by a C and a length. A data file may either be fixed length or variable length. For fixed length records, create a binary file, and place the letter F in the relcat’s format field. For variable length records, create a text file, and delimit the records with the character | , and place the letter V in the relcat’s format field. For now, only the catalogs exist; since both are fixed length files, both will contain an F in the format field. Later assignments will clarify the data format. 3. Commands Read commands from the standard input. Do not prompt for them, however. Your program will be run against a test script, which may not work with prompting. Include simple error checking - display an error message on incorrect commands. See below for examples. a. Show Catalogs. Command: S Display the contents of the relcat and attrcat, in neat tabular format, with column headings and reasonable spacing.

b. Create File. Command: C filename format attribute-list. Create a new file with the given attributes. Make one new entry in the relcat, and as many entries in the attrcat as needed. Create the new file with 0 length, then close it. Example: C employee F I id C 10 name D salary. This denotes the fixed length record file employee( int id, char name[10], double salary). c. Quit. Command: Q. Close the database and exit the program. Example Here is an example sequence of commands: hw2 mydatabase - create subdirectory mydatabase, create relcat, create attrcat S - display the initial catalogs (only entries for relcat and attrcat) C student V C 20 name D gpa - create a file called “student”, which will (eventually) contain variable length records with the student name and gpa as data fields. Make one entry in the relcat (for student) and two entries in the attrcat (one each for name and gpa). C employee F C 40 name I id D salary - create a file called “employee”, which will (eventually) contain fixed length records with the employee name, id, and salary as data fields. Make one entry in the relcat (for employee) and three entries in the attrcat (one each for name, id, and salary). S - display the catalogs; entries for student and employee should be present Q - close the database and exit; do not remove any files. The subdirectory mydatabase will continue to exist and contain the files relcat, attrcat, student, and employee. Deliverables Be sure to test your program carefully. It should handle most reasonable errors - when in doubt, ask. Submit a printout of your program, a printout of your make file and a diagram of classes used and their relationships in a manila envelope with your names and login id on the front. Copy an executable version of your program named hw2 in your home directory. (Note: you cannot name your homework 2 directory “ hw2 ”, since you will be moving the executable file to your home directory.) Make sure the permissions are set correctly by doing the command chmod go+rx hw2 after you copy the executable to your home directory.