StudentNumber LastName FirstName Age Class
Attributes can be unique or nonunique. In the example, StudentNumber is unique, meaning that no two students may have the same number. The other four attributes are nonunique, since several different students may have the same LastName, many may have a common FirstName, and both Age and Class (i.e. number of years in college) will have a lot of students sharing the same values.
To provide rapid access to data, database systems use indexes. Each index allows the database to be searched (efficiently) on a selected attribute called the key of that index. In our example, StudentNumber is the primary key, because it is unique, but indexes can also be built with other keys, unique or not, when fast access on those keys is desired.
Index structures may be composed of search trees, hash tables,
and other data structures.
In this assignment you will use binary search trees for the indexes.
In the next assignment, which will
be small, but will build on this one, you will use hash tables for indexes.
In real database systems, the most common index structures are
B-Trees and hash tables that can handle data on disk efficiently.
Your job is to design a system that reads a relation from disk into memory and creates indexes for the specified attributes, both unique and nonunique. Because we are allowing nonunique keys, the nodes of the search trees must point to lists of all the records with the key values stored in these nodes. (This will make parts of your code reusable - so bear that in mind since we will get to hash tables.) You will be extending the structures and functions the book gives for binary search trees, rather than just copying the author's code. While you're at it, think about how you can improve them and make them more readable (it will be a definite plus for you).
Design and implement an ADT for extended binary search trees that can handle the following operations:
6413578 Buckingham Christopher 29 4and I = 1, then 6413578 would be inserted into the StudentNumber index with a pointer to R. For the same record with I = 2, the key 29 would be inserted into the Age index with a pointer to R. Note that for primary keys, trying to insert a duplicate record (with a key K that is already in the primary key index) should result in the following error message:
You will also need a function (or method) to delete a record from the whole database. It should use the routines DeletePrimary and DeleteSecondary, explained above.
For example, Delete(6413578) should invoke the following sequence of operations:
If there is no record with primary key K in the database, the message
"DELETE ** RECORD NOT FOUND WITH KEY K"
should be printed out.
Initially, you will read in all records of the database from a file, store the records in your database array, and create the two indexes for StudentNumber and Age. This process will test Insert.
Once the database and indexes are set up, the user will want to issue commands that either modify the database, or cause a set of records to be printed. You should be able to handle the following user commands:
For the purpose of these user commands, the keyname will be a single character, the first character of the full key name, ie. 'S' for StudentNumber, 'A' for Age. We will provide a set of test commands and the database created from records you have provided us with.
As was the case with Programming Project #1, your code should include the following block at the top of each source file:
and for each function or class method:
As always, be sure to start early and come to us with questions before the last 24 hours leading to the due date.
Download the text file, containing the database records students in this class have submitted.
Download the text file, containing sample queries that should be performed (in the given order) on your database, once you have implemented all necessary functionality, as discussed above.
Turn in a hardcopy of your program and its output in class on Wednesday, November 1.
Make sure to write your e-mail address on your
hardcopy submission.
The output should show all tests that
you ran and their results, including all the user commands we
gave you and anything you added (such as putting a record with
duplicate StudentNumber into the data, so your program can reject it).
There will be NO ELECTRONIC TURN-IN.
However, if TAs have questions about your programs,
they may ask you to e-mail them your code, so have it ready just in case.
Good luck!