Project

Introduction

This document is intended to give you all the information you need to work on the Project for the CS106 course. it is divided into five sections: Problem Statement, Organization of the Project, Methodological Guidelines, Stylistic Guidelines and Important Dates.

Problem Statement

You will have to design and implement a database. This is to be done in two stages. Stage 1 consists of the preparation of a Project Proposal, which should specify all features of your design. Stage 2 comprises the actual implementaion of the database as an object-oriented package. Certain aspects of the design and implementation, as described below, are standardized ; the rest are up to you. In particular, the specific database to be implemented is your choice.

Organization of the Project

Classes: A reasonable project design would involve the definitions of two classes - Record and Database. The Record class will have data members corresponding to the various fields of a record ( these will differ depending on the database you're implementing) and methods to get and set the values of fields, as well as to print a Record. There should be a key field that uniquely identifies the record it belongs to.

The Database class should have a data member correponding to a collection of Records - it would be most convenient to let this data member be an array. There should also be a data member that holds the size of a Database object - this is necessary because we allow records to be added to or deleted from a database. Various other data menbers might also be required to maintain the state of a Database object. The class must also have methods to do the following : initialize a Database object, change (add a record to / delete a record from/ modify a record of) a Database object and answer queries made about Database objects satisfying conditions of certain types. These will be elaborated in the section on Methodological Guidelines.

Files: Your project should comprise two cpp files Database.cpp and Main.cpp, and a header file Database.h . The header file should contain the declarations of the classes Record and Database. The file Database.cpp should contain the definitions of the methods in the classes Record and Database. Maintaining the declarations and definitions in separate files corresponds to separating the implementation details of the database from the interface to the user (changing the implementation should not require a recompilation of the user's program). Database.cpp should #include the Database.h file and be compiled into an object file. The Main.cpp file, which serves to test the correctness of the class definitions, should also #include the Database.h file (this represents the visiiblility of the interface to the user) and be compiled into an object file separately from the Database.cpp file. The two object files should be linked together only when you run the project.

Methodological Guidelines

The following is a summary of the essential methods that should be defined in the class Database( I don't insist on extensive error checking, so as not to obscure the more essential conceptual aspects of the project). In addition, you should define methods relevant to our particular choice of database.

Initialization: The class Database should have a default constructor - for example, one that sets the size of the database to 0. It should also have a constructor that takes a file name as parameter and, assuming some format in which records are stored in the file, copies these records into the newly created Database object. The parameter for this constructor should have type const char* since you want to be able to pass a literal string to it as an argument.

Modification : The class needs atleast three methods that can be used to modify the database - Add,Delete and Modify. The Add method should take in a reference to Record as parameter (it is preferable to pass a record to a function by reference rather than value - this avoids expensive copying) and return a boolean value indicating success or failure of the operation. The Delete method should take in a reference to Record or a Record key as parameter and return a value indicating success/failure. Modify should take in a reference to Record or a Record key and return a reference to Record ( this last point is very important - only by using the reference returned by the method can the record be changed).

Querying: There should be methods that return records satisfying conditions of certain types. The most basic type of condition is one in which the value of a particular field is specified and a record with this field value is asked for. Minimally, methods corresponding to this type of condition should be defined.

Miscellaneous: If the key field is of type integer, and the records are not stored by default in sorted order of key field, there should be a Sort() method. There should also be a destructor that writes the changed database back into a file, if the relevant Database object was initialized from a file.

Stylistic Guidelines

Indentation : All code should be indented in a consistent and reasonable manner. Credit will be deducted if this is not done.

Documentation: Your code should be extensively commented. Along with each method in the header file, you should include a description of what the method does that is atleast moderately enlightening.

Important Dates

March 2 (Wednesday) : Submission of Project Proposal

March 14 (Monday) : Submission of Project