Database Management Library


Database Management Library is a relational database management system contained in a C++ programming library. The DBL source code is available under the terms of the GNU General Public License.
DBL was fully developed within two weeks, as a holiday programming project.
It aims to be easy and simple to use for C++ programming.

Design

DBL is a library and becomes an integral part of the application program. Unlike client–server model database management systems that are standalone process with which the application program communicates. The application software uses DBL's functionality through function calls.

Sample programs

Creating a simple database

This is a basic program that creates a simple database. However, as this task must be done usually once, it can be done by the DBL command-line interface.

  1. include "dbl.h"
int main

  1. include
int main

Library structure

Class database

This class stores the database name and its tables.
The main functions are:

char *name; //get the database name
char *name; //set the database name
void new_tab; //create a new table
table *get_tab; //return the pointer to the table

Useful functions that use the class database are:

void write; //write the database structure into a file
friend void read; //read the database structure from a file
friend void del; //delete the database and its tables files
friend void print; //print the database on the screen

Class table

This class stores the table name and its structure, the columns of the table.
The main functions are:

char *name; //get the table name
char *name; //set the table name
void add_col; //add a new column to the table
void add_col;
column *get_col; //get the column by its index
column *get_col; //get the column by its name
int num_col; //get the number of columns in the table
//finish the structure of the table.
//This function must be called after adding all columns or after reading the structure of the table from a file
void set_structure;
row new_row; //get a new row with the table structure

Useful functions that use the class table are:

void write; //write the table structure into a file
void read; //read the table structure from a file
friend void del; //delete the table files, header and data files
void print; //print the table on the screen
friend std::ostream &operator<<; //print the table structure
int num_row; //get the number of rows in the data file of the table

Class row

This class stores the columns of the table and the data to be stored in the data file.
The main functions are:

void set; //set the storage of a column by its index
void set; //set the value to be stored in a column by its index
storage *get; //get the storage from the a column by its index

Useful functions that use the class row are:

void write; //write the data in the data file of the table
void read; //read the data from the data file of the table
void del; //delete the data from the data file of the table

Class storage

This class stores the column and a value for that column.
The main functions are:

char *value; //get the value being stored by the object
void value; //set the value to be stored
void value; //set the value to be stored, a C-style string and all functions of the class column.

Useful functions that use the class storage are:

int get_int; //get the integer being stored
char get_char; //get the char being stored
bool get_bool; //get the bool being stored
float get_float; //get the float being stored
double get_double; //get the double being stored

Class column

This class stores the name and the structure of a column.
The main functions are:

char *name; //get the name of the column
char *name; //set the name of the column
char type; //get the type of the column
char type; //set the type of the column
int length; //get the length of the array that the column can hold
int length; //set the length of the array that the column can hold, len>0
void pkey; //set if the column is the primary key or not
char pkey; //get if the column is the primary key or not
int total_size; //get the total size, in bytes, that the column can hold

Class index

This class stores the indexes of a table.
The main functions are:

int seek; //look for a value in the indexes
int seek; //look for a C-style string in the indexes

Useful functions that use the class index are:

void write; //write the indexes of a table into a file
void read; //read the indexes from a file

DBL command-line interface

By the DBL command-line interface program one can create a database, a table, and add columns to this table, besides other operations such as printing.