Text Based Database (C++)

Click here to view the code on GitHub: 



This program is essentially a simple database written in C++, which stores text-based records in “.dat” files. The user can retrieve content from a specific record, create a new record with new information, delete existing records, or update existing records. The basic structure of the program is as follows:

Data file (“.dat”)
|____*Child 1 _____node . . .
|____*Child 2 _____node . . .
(Binary tree structure continues . . .)

The highest-level class is the “database” class. It manages file streams which access the appropriate “.dat” files as defined by the user. The “database” class also manages parsing of “.dat” files for required information. Records and fields are bounded by a set of arbitrarily defined opening/closing tags much like those used in HTML. As a file is parsed, proper algorithms are used to locate records in the file (according to the tags) and attach associated fields to the current record.

As records are extracted from the file, they are inserted into an instance of the class “recordList” where memory is dynamically allocated for them. The “recordList” class is an alphabetically sorted, binary-tree, linked list. Newly inserted records are sorted according to the content of their “header” fields. This data structure is where all records currently in memory reside.

The “recordList” object consists of dynamically generated nodes (struct objects). Each node possesses pointers to both of its child nodes (if any), as well as a pointer to an instance of the class “record”. The “record” class is at the lowest level of the program. Fields within each record are stored as attributes of “record” class objects. Various member functions for alphabetical or numerical comparison of fields are also contained in this class.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: