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:

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: