Programming Assignment 3—Database
Contents
Overview
In this PA, you will create a database. You will get to choose what kind of data your database will store. However, there is a set of specifications that your database and program must adhere to (see below).
For example, suppose I decided to make a Rolodex. I will store the following attributes about each contact:
- First name
- Last name
- Phone number
- Address
- Business
- Birthday
Each attribute of a contact be saved to its own line in the database file, so each contact will have a total of seven lines associated with it.
The program will allow me to search on any field. The program will also provide the ability to count the number of entries with a field matching a given value for any field.
Here's an example of me running it.
$ rolodex contacts.db ============================================================== Welcome to the Digital Rolodex! ============================================================== Database "contacts.db" does not exist; it will be created on exit. Please select an option: [a]dd contact, [r]emove contact, [u]pdate contact, [s]elect contacts, [c]ount contacts, or [q]uit: a Please enter the following information about the contact you'd like to add: First name: Bob Last name: Smith Phone #: 555-555-5555 Email: bsmith@mail.com Address: 1 Main St., Boston, MA Business: Acme Electronics Birthday: Jan. 1, 1980 Contact added. Please select an option: [a]dd contact, [r]emove contact, [u]pdate contact, [s]elect contacts, [c]ount contacts, or [q]uit: s Please enter the field you'd like to match on ([f]irst name, [l]ast name, [p]hone #, [e]mail, [a]ddress, [b]usiness, b[i]rthday: l Please enter the value you'd like to match: Smith 1 contact(s) found: Bob Smith Acme Electronics 1 Main St., Boston, MA 555-555-5555, bsmith@mail.com Birthday: Jan. 1, 1980 Please select an option: [a]dd contact, [r]emove contact, [u]pdate contact, [s]elect contacts, [c]ount contacts, or [q]uit: q Saving database to "contacts.db". Now exiting. Bye!
The program saved the database of contacts to contacts.db (which was provided as a command line argument when running the program). I only added one contact, and here's what contacts.db looks like:
Bob Smith 555-555-5555 bsmith@mail.com 1 Main St., Boston, MA Acme Electronics Jan. 1, 1980
If I run the program again and provide the already existing contacts.db database file, the program will load the contents in, so our contact will be available. Here's another run of the program where we add an additional contact to the existing database:
$ rolodex contacts.db ============================================================== Welcome to the Digital Rolodex! ============================================================== Database "contacts.db" exists; loading now. This will be updated on exit. Please select an option: [a]dd contact, [r]emove contact, [u]pdate contact, [s]elect contacts, [c]ount contacts, or [q]uit: a Please enter the following information about the contact you'd like to add: First name: Jane Last name: Smith Phone #: 222-222-2222 Email: jsmith@mail.com Address: 10 Pine St., Boston, MA Business: IRS Birthday: Feb. 1, 1978 Contact added. Please select an option: [a]dd contact, [r]emove contact, [u]pdate contact, [s]elect contacts, [c]ount contacts, or [q]uit: s Please enter the field you'd like to match on ([f]irst name, [l]ast name, [p]hone #, [e]mail, [a]ddress, [b]usiness, b[i]rthday: l Please enter the value you'd like to match: Smith 2 contact(s) found: Bob Smith Acme Electronics 1 Main St., Boston, MA 555-555-5555, bsmith@mail.com Birthday: Jan. 1, 1980 Jane Smith IRS 10 Pine St., Boston, MA 222-222-2222, jsmith@mail.com Birthday: Feb. 1, 1978 Please select an option: [a]dd contact, [r]emove contact, [u]pdate contact, [s]elect contacts, [c]ount contacts, or [q]uit: c Please enter the field you'd like to match on ([f]irst name, [l]ast name, [p]hone #, [e]mail, [a]ddress, [b]usiness, b[i]rthday: b Please enter the value you'd like to match: IRS 1 contact(s) matched business = IRS. Please select an option: [a]dd contact, [r]emove contact, [u]pdate contact, [s]elect contacts, [c]ount contacts, or [q]uit: q Saving database to "contacts.db". Now exiting. Bye!
This updates the contacts.db file to the following:
Bob Smith 555-555-5555 bsmith@mail.com 1 Main St., Boston, MA Acme Electronics Jan. 1, 1980 Jane Smith 222-222-2222 jsmith@mail.com 10 Pine St., Boston, MA IRS Feb. 1, 1978
This example is meant to serve as just that, and example. Your database does not need to work exactly like this. However, it does need to meet all of the specifications laid out below.
(Back to top)Specifications
Your completed submission must meet the following requirements:
- the database and your choices for the requirements below "make sense" and is not something we did in class (e.g., courses or a digital Rolodex)
- each entry in the database includes at least four pieces of information
- the following operations are included:
- add an entry
- remove an entry
- update an existing entry
- select entries that match some condition
- at least one aggregation operation (e.g., sum over a numeric field or count the number of matching entries)
- the database is stored to a file and can be loaded back in
- the name of the database file can be specified as a command line argument
- uses at least one well designed struct or class
- uses well designed functions as needed
- uses pass-by-reference and pass-by-value appropriately
- is wholly of your own design and programming (i.e., don't work with others)
- it compiles and runs
Milestones
Milestone 1: Planning and program skeleton
For this milestone, you will describe what your database will store, how it will
work, and create a skeleton complete with stubs and pseudo code. In your C++
file just below the #include
statements, etc., add a comment that
looks something like:
// Database: My database will store ..... It works as follows... // ...
In this comment, you should include what data your database will store and a short description of how it will work.
The C++ file should include:
- a definition for the struct or class you will use
- all necessary function/method declarations and stubs
- pseudo code inside of each function/method (including main) stub
- JavaDocs above each function/method definition
You program must compile and run.
Upload your C++ file to here. You can view the rubric here.
Milestone 2: 50% implemented
For this milestone, implement 50% of your functions and methods. Your program must compile and run.
Submit your .cpp file here. You can view the rubric here.
(Back to top)Milestone 3: Completed Project
Finish implementing your project and submit it. Your program must compile and run.
Submit your .cpp file here. You can view the rubric here.
(Back to top)