CPSC 350: Data Structures Assignment 5, Version 1.2
Building a Database with Binary Search Trees
In this assignment, you will push your C++ skills to the limit by implementing a simple database system using binary search trees. Though the end product will be a far cry from Oracle or MySQL, your DB will allow the user to insert, delete, and query data. The data itself will be persistent (stored on disk), so that you may process it over several sessions.
The DB itself will contain data that would be commonly found in a university’s computer system. In our case, this information consists of student and faculty records. The information for each will be stored in its own tree (or “table” in DB terminology).
Though I will provide you with a general outline of the program, many of the implementation details will be up to you. In the same spirit, I will give you a point in the right direction as far as some of the C++ techniques go, but it will also be your responsibility to research the techniques in more detail.
The tables that store the records in your DB will be binary search trees. The nodes will consist of Student or Faculty objects, depending on the tree. The tree will be sorted on the primary key value of the nodes, which in our case will be faculty and student Ids.
Your first job will be to build a BST implementation supporting the usual operations (including delete). This should not be difficult in and of itself. Just be sure to use templates to make your implementation generic, and overload operators as required.
Student records will be stored in a Student class. Student records contain a unique student ID (an integer), a String name field, a string level field (Freshman, Sophomore, etc), a String major field, a double GPA field, and an integer advisor field, which will contain the Faculty ID of their advisor. These are the only fields the class contains.
The Student class must overload equality, less than, greater than operators, etc. so that we can compare them to one another.
Faculty records are similar to student records, and will also require overloaded operators.
Faculty records contain an integer Faculty ID, a String name, a String level (lecturer, assistant prof, associate prof, etc), a String department, and a list of integers corresponding to all of the faculty member’s advisees’ ids. These are the only fields the class contains.
How the Program Should Work
Your program will keep references to both the faculty and student tables in memory. These references are simply BSTree instances. For convenience, we will call them masterFaculty and masterStudent.
When the program starts, it should check the current directory for the existence of 2 files “facultyTable” and “studentTable”. These files correspond to the BSTrees containing the faculty and student data. If neither of these files exist, then masterFaculty and masterStudent should be initialized as new, empty trees. If the files do exist, then they should be read into the appropriate variables. (See appendix A)
Once the tables have been set up, a menu should be presented to the user to allow them to manipulate the databases. At a minimum (if you do more you’ll get more credit), the choices should include:
Print all students and their information (sorted by ascending id #)
Print all faculty and their information (sorted by ascending id #)
Find and display student information given the students id
Find and display faculty information given the faculty id
Given a student’s id, print the name and info of their faculty advisor
Given a faculty id, print ALL the names and info of his/her
Add a new student
Delete a student given the id
Add a new faculty member
Delete a faculty member given the
Change a student’s advisor given the student id and the new faculty
Remove an advisee from a faculty member given the ids
When a command is selected, you should prompt the user for the required data, and execute the command. If there are any errors, you should inform the user and abort the command.
All of the above commands should enforce referential integrity. That is to say, a student can not have an advisor that is not in the faculty table. A faculty member can’t have an advisee in the student table. If a faculty member is deleted, then their advisees must have their advisors changed, etc. Your commands will be responsible for maintaining referential integrity. If a user issues a command that would break referential integrity, you should warn them and abort the command, or execute the command and fix any violations as appropriate.
After each command is executed, the menu should be displayed again, and the user allowed to continue.
The Rollback command is used if the user realizes they have made a mistake in their data processing. The Rollback command will “undo” the previous action, but only if that action changed the structure of the DB. Your program should allow the user to roll back the last 5 commands that CHANGED the DB. (Commands that simply display data do not count.) This will involve keeping snapshots of the DB before and after commands are issued. The implementation details for this are left up to you.
If the user chooses to exit, you should write the faculty and student tables back out to the “facultyTable” and “studentTable” files (see appendix A), clean up, and quit gracefully.
At this point you should realize this is a non-trivial assignment. To successfully complete it, you need to make use of your best OO design and programming skills. Think modularly, sketch out a solution before you start coding, and START EARLY. Sleeping is optional, but not recommended.
-You may work in groups of 2 on this assignment. (HIGHLY Recommended)
-All code must be your own
-Develop on any platform you wish, but make sure it compiles/runs with g++ within your Linux Docker container
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.
Get Free Quote!
263 Experts Online