Database Management Library

Last updated
Database Management Library (DBL)
Developer(s) Rodrigo C. O. Rocha
Initial releaseJuly 2, 2010 (2010-07-02)
Stable release
1.0 / July 2, 2010;12 years ago (2010-07-02)
Written in C++
Type Embedded RDBMS
License GNU General Public License
Website sites.google.com/site/rcorcs/download/library sourceforge.net/projects/dblibrary

Database Management Library (DBL) is a relational database management system (RDBMS) contained in a C++ programming library. The DBL source code is available under the terms of the GNU General Public License.

Contents

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.

#include"dbl.h"intmain(){path("D:\\");//set the path to the folder where the files will be storeddatabasedb("mydatabase");//mydatabase is the name of the databasedb.new_tab("customer");//create a new table called customer in the databasewrite(db);//write the database structure into a filecharpkey=1;table*tab=db.get_tab("customer");//get the table customer from the databasetab->add_col("cod",INTEGER,1,pkey);//add a column called cod to the table customertab->add_col("name",CHARACTER,32);//add a column called name to the table customertab->add_col("brithdate",INTEGER,3);tab->add_col("sex",CHARACTER,1);tab->add_col("phone",INTEGER,1);tab->set_structure();write(*tab);//write the table structure into filescreate_data_file(*tab);//create the data file of the table customerreturn0;}

Library structure

Class database

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

char*name();//get the database namechar*name(char*dbname);//set the database namevoidnew_tab(char*tabname);//create a new tabletable*get_tab(char*tabname);//return the pointer to the table

Useful functions that use the class database are:

voidwrite(database&db);//write the database structure into a filefriendvoidread(database&db);//read the database structure from a filefriendvoiddel(database&db);//delete the database and its tables filesfriendvoidprint(database&db);//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 namechar*name(char*dbname);//set the table namevoidadd_col(column&c);//add a new column to the tablevoidadd_col(char*col_name,charcol_type,intcol_len=1,charpkey=0);column*get_col(intidx);//get the column by its indexcolumn*get_col(char*name);//get the column by its nameintnum_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 filevoidset_structure();rownew_row();//get a new row with the table structure

Useful functions that use the class table are:

voidwrite(table&t);//write the table structure into a filevoidread(table&t);//read the table structure from a filefriendvoiddel(table&t);//delete the table files, header and data filesvoidprint(table&t);//print the table on the screenfriendstd::ostream&operator<<(std::ostream&o,table&t);//print the table structureintnum_row(table&t);//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:

voidset(intidx,storage&s);//set the storage of a column by its indexvoidset(intidx,void*v);//set the value to be stored in a column by its indexstorage*get(intidx);//get the storage from the a column by its index

Useful functions that use the class row are:

voidwrite(table&t,row&r,intidx);//write the data in the data file of the tablevoidread(table&t,row&r,intidx);//read the data from the data file of the tablevoiddel(char*file,table&t,intidx);//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 objectvoidvalue(void*val);//set the value to be storedvoidvalue(char*val);//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:

intget_int(storage&s);//get the integer being storedcharget_char(storage&s);//get the char being storedboolget_bool(storage&s);//get the bool being storedfloatget_float(storage&s);//get the float being storeddoubleget_double(storage&s);//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 columnchar*name(char*n);//set the name of the columnchartype();//get the type of the columnchartype(chart);//set the type of the columnintlength();//get the length of the array that the column can holdintlength(intlen);//set the length of the array that the column can hold, len>0voidpkey(charb);//set if the column is the primary key or not (0 is false, 1 is true)charpkey();//get if the column is the primary key or notinttotal_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:

intseek(void*val);//look for a value in the indexesintseek(char*val);//look for a C-style string in the indexes

Useful functions that use the class index are:

voidwrite(table&t,index&idx);//write the indexes of a table into a filevoidread(index&idx);//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.

Related Research Articles

The syntax of the C programming language is the set of rules governing writing of software in the C language. It is designed to allow for programs that are extremely terse, have a close relationship with the resulting object code, and yet provide relatively high-level data abstraction. C was the first widely successful high-level language for portable operating-system development.

<span class="mw-page-title-main">Pointer (computer programming)</span> Object which stores memory addresses in a computer program

In computer science, a pointer is an object in many programming languages that stores a memory address. This can be that of another value located in computer memory, or in some cases, that of memory-mapped computer hardware. A pointer references a location in memory, and obtaining the value stored at that location is known as dereferencing the pointer. As an analogy, a page number in a book's index could be considered a pointer to the corresponding page; dereferencing such a pointer would be done by flipping to the page with the given page number and reading the text found on that page. The actual format and content of a pointer variable is dependent on the underlying computer architecture.

In computer science, a mutator method is a method used to control changes to a variable. They are also widely known as setter methods. Often a setter is accompanied by a getter, which returns the value of the private member variable.

<span class="mw-page-title-main">Rope (data structure)</span> Data structure for storing strings

In computer programming, a rope, or cord, is a data structure composed of smaller strings that is used to efficiently store and manipulate a very long string. For example, a text editing program may use a rope to represent the text being edited, so that operations such as insertion, deletion, and random access can be done efficiently.

A database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of additional writes and storage space to maintain the index data structure. Indexes are used to quickly locate data without having to search every row in a database table every time said table is accessed. Indexes can be created using one or more columns of a database table, providing the basis for both rapid random lookups and efficient access of ordered records.

<span class="mw-page-title-main">C data types</span> Data types supported by the C programming language

In the C programming language, data types constitute the semantics and characteristics of storage of data elements. They are expressed in the language syntax in form of declarations for memory locations or variables. Data types also determine the types of operations or methods of processing of data elements.

MyISAM was the default storage engine for the MySQL relational database management system versions prior to 5.5 released in December 2009. It is based on the older ISAM code, but it has many useful extensions.

In computer programming, the term hooking covers a range of techniques used to alter or augment the behaviour of an operating system, of applications, or of other software components by intercepting function calls or messages or events passed between software components. Code that handles such intercepted function calls, events or messages is called a hook.

Automata-based programming is a programming paradigm in which the program or part of it is thought of as a model of a finite-state machine (FSM) or any other formal automaton. Sometimes a potentially infinite set of possible states is introduced, and such a set can have a complicated structure, not just an enumeration.

sizeof is a unary operator in the programming languages C and C++. It generates the storage size of an expression or a data type, measured in the number of char-sized units. Consequently, the construct sizeof (char) is guaranteed to be 1. The actual number of bits of type char is specified by the preprocessor macro CHAR_BIT, defined in the standard include file limits.h. On most modern computing platforms this is eight bits. The result of sizeof has an unsigned integer type that is usually denoted by size_t.

Entity–attribute–value model (EAV) is a data model to encode, in a space-efficient manner, entities where the number of attributes that can be used to describe them is potentially vast, but the number that will actually apply to a given entity is relatively modest. Such entities correspond to the mathematical notion of a sparse matrix.

A column-oriented DBMS or columnar DBMS is a database management system (DBMS) that stores data tables by column rather than by row. Benefits include more efficient access to data when only querying a subset of columns, and more options for data compression. However, they are typically less efficient for inserting new data.

This article describes the syntax of the C# programming language. The features described are compatible with .NET Framework and Mono.

Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications—which may run either on the same computer or on another computer across a network. Microsoft markets at least a dozen different editions of Microsoft SQL Server, aimed at different audiences and for workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users.

Raima Database Manager is an ACID-compliant embedded database management system designed for use in embedded systems applications. RDM has been designed to utilize multi-core computers, networking, and on-disk or in-memory storage management. RDM provides support for multiple application programming interfaces (APIs): low-level C API, C++, and SQL(native, ODBC, JDBC, ADO.NET, and REST). RDM is highly portable and is available on Windows, Linux, Unix and several real-time or embedded operating systems. A source-code license is also available.

The MySQLi Extension is a relational database driver used in the PHP scripting language to provide an interface with MySQL databases.

InfinityDB is an all-Java embedded database engine and client/server DBMS with an extended java.util.concurrent.ConcurrentNavigableMap interface that is deployed in handheld devices, on servers, on workstations, and in distributed settings. The design is based on a proprietary lockless, concurrent, B-tree architecture that enables client programmers to reach high levels of performance without risk of failures.

In database management systems (DBMS), a prepared statement, parameterized statement, or parameterized query is a feature used to pre-compile SQL code, separating it from data. Benefits of prepared statements are:

PL/SQL is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database, Times Ten in-memory database, and IBM Db2. Oracle Corporation usually extends PL/SQL functionality with each successive release of the Oracle Database.

<span class="mw-page-title-main">ObjectDatabase++</span>

ObjectDatabase++ (ODBPP) is an embeddable object-oriented database designed for server applications that require minimal external maintenance. It is written in C++ as a real-time ISAM level database with the ability to auto recover from system crashes while maintaining database integrity. Its unique transaction process allows for maintenance of both the indexes and tables, preventing double allocation of index entries that could prohibit rollback of transactions.