Assignment 5: A student
records database with vectors (group)
Due: 10/18 at 11:59 p.m.
Libraries You May Use
In this assignment, we will implement a simple DataBase Management System
(DBMS) and a database built with the DBMS to store the student records for
CSCI325 Fall 2020 class.
What you must implement:
- A vector of student structs or objects storing student records.
A student struct or class (your choice) containing following
information of a student:
- ID - (string), allow leading 0's
- First Name - (string)
- Last Name - (string)
- vector grades - A vector of assignment grades, where a grade is between
0 and 100 inclusive.
Note: Please use the std::vector
class to store your data. Do not implement your own vector for this assignment.
You must also implement the following minimum functionality (methods):
Note: In general your methods should not be doing input/output with the user directly. You should interact with the user in the main() and pass information to your methods using parameters.
- A default constructor/destructor database and ~database
- import_from_file - takes a string file name as a parameter and reads the
student records from the file with that name. In the file, all items of one
student should appear in one line and separated by a space. Different
students should appear in different lines in the file.
- For example, a student with ID=1001001, FIRSTNAME="John", LASTNAME="Smith"
and 5 assignment grades 84, 75, 89, 54, 49 should appear in file in one line
as: 1001001 John Smith 84 75 89 54 49
- While importing student records from a file, you should search for an
insertion point in the vector by traversing the vector to insert a new
student record in the middle of the list in the ascending order of ID (i.e., sorted by the
- export_to_file - takes a string with a file name as a parameter
and writes the student records to the file with that name. The format of
export file should be the same as that of import file.
- update - update a student's grade with a command in the
following syntax format (i.e. the user should type the command in the
required format when choosing to update the database):
- update student set ASSIGNMENTX = 69
where ID = "0001123"
- If no student in the database has that ID or no ASSIGNMENTX exists,
nothing will happen; otherwise, the student with ID "0001123" should have
his ASSIGNMENTX grade updated to 69, where X in ASSIGNMENTX is a number >=1,
e.g. ASSIGNMENT7 means the student record should include grades of at least
- add - add a new student record into the database with a command
in the following syntax format:
- add student 1001001 John Smith 84 75
89 54 49
- Find right location to insert the student into the vector with ID
"1001001" so the students in the vector are sorted by their IDs. There is no
limitation on the number of grades provided in the command.
- The first 3 items of a student record provided by the
add command should be ID, FIRSTNAME,
- delete - delete a student record from the database with a
command in the following syntax format:
- delete student where ID = "1001001"
- If no student in the database has that ID, nothing will happen but an
error to user; otherwise, the student with ID "1001001" should be deleted
from the database.
- select - look up a student or students with ID, LASTNAME,
or both LASTNAME and FIRSTNAME using a command in the following syntax
- select student where ID = "1001001"
- Should list the record of the student with
ID "1001001" in one line: 1001001 John Smith 84 75 89 54 49
- select student where LASTNAME =
- All students with LASTNAME "smith" should be listed, one line for each
- report - calculate average grade for each student (with one
decimal place and assuming all assignments having the equal weight) and
convert the average grade to the letter grade following UTM conversion.
Print student records including average grades and letter grade to the
screen and a file with a given name. Each student record appears in one line
and all columns should be properly aligned.
Data File Format
You should provide a data file for testing purposes. Your program should read and write the same file format (i.e., the file output of your program should be able to serve as your program's input). The format is as follows:
student_id1 first_name1 last_name1 assignment1 assignment2 assignment3 ...
student_id2 first_name2 last_name2 assignment1 assignment2 assignment3 ...
Where each entry has an appropriate value (e.g., student_idi may be
1001001, first_namei may be John, last_namei may be Doe, and
assignmenti for this student may be
As your program reads the file you should use insert_sorted to store the data in order (i.e., an unsorted file should get sorted by your program).
Your program's documentation should be consistent with previous assignments (see previous assignments and examples for more information).
You are not being provided with a driver. Instead, you are asked to implement a driver that manages interaction with the user as well as the interaction with your
vector-based database. The driver should have a loop that gives the user the following choices:
Welcome to the
UTM Proud Database! You may select one of the following options:
Import from a file
2 Export to a file
3 Update a record
4 Add a student
5 Delete a student
8 Exit this program
Please enter your choice now: [user enters their choice here]
Note that this implies the use of a loop in your main() that allows the user to keep selecting from the list until they are done.
Also note that your method behavior should be consistent, and should prevent against simple errors: printing an empty database to a file should result in an empty file, your program should be able to read back in a database that it has written to a file, etc.
What you must turn in.
Electronically a single zip file, with the name LASTNAME_FIRSTNAME.zip.
Your zip file should extract into a directory with the same name as the zip (please make sure to put your files in a separate directory before submission). Your zip should include all files necessary to compile and run your program including:
- main.cpp - Should implement your main file, include other files.
- database.h - The definition for the database class.
- database.cpp - The method definitions for the database class.
- database.txt - A sample student record file that can be
imported from. Note you should design the content of the file so that it
can be used to test if your program satisfy all related requirements
above, e.g, the records are not sorted with ID so that you can test if
your program can sort them correctly with ID after importing.
- report.txt - A sample report file output from your program.
You should list all files
submitted and a brief statement about the content of each file.
You should provide a detailed user manual about how to use your program
so that users can use your programs without having to look at your code.
You should document how well you have completed all required features.
You may document any extra features you have implemented that might
You may document what you have
learnt and any problems that you still do not understand.
- Any other source files or ASCII data files required to test your program.
- Please do not turn in object or executable code.
Note: Your program must compile and run on CS1 (or a UD lab machine) or it will not be graded. Please see the syllabus for details.