Jump to content

Библиотека управления базами данных

Библиотека управления базами данных (DBL)
Разработчик(и) Родриго, Колорадо Роча
Первоначальный выпуск 2 июля 2010 г. ( 02.07.2010 )
Стабильная версия
1.0 / 2 июля 2010 г .; 14 лет назад ( 2010-07-02 )
Написано в С++
Тип Встроенная СУБД
Лицензия Стандартная общественная лицензия GNU
Веб-сайт сайты .Google /сайт /rcorcs /скачать / библиотека .сеть /проекты /dblibrary

Библиотека управления базами данных ( DBL ) — это система управления реляционными базами данных (RDBMS), содержащаяся в C++ программирования библиотеке . DBL Исходный код доступен на условиях GNU General Public License .

DBL был полностью разработан за две недели как проект праздничного программирования.

Его цель — сделать его легким и простым в использовании для программирования на C++.

DBL представляет собой библиотеку и становится неотъемлемой частью прикладной программы. В отличие от модели клиент-серверной модели системы управления базами данных представляют собой автономный процесс , с которым взаимодействует прикладная программа. Прикладное программное обеспечение использует функциональность DBL посредством вызовов функций .

Примеры программ

[ редактировать ]

Создание простой базы данных

[ редактировать ]

Это базовая программа, создающая простую базу данных. Однако, поскольку эту задачу обычно необходимо выполнить один раз, ее можно выполнить с помощью интерфейса командной строки DBL .

#include "dbl.h"

int main()
{
    path( "D:\\" ); //set the path to the folder where the files will be stored

    database db("mydatabase");  //mydatabase is the name of the database
    db.new_tab("customer");  //create a new table called customer in the database
	
    write(db);  //write the database structure into a file

    char pkey = 1;
    table *tab = db.get_tab("customer"); //get the table customer from the database
    tab->add_col("cod", INTEGER, 1, pkey);  //add a column called cod to the table customer
    tab->add_col("name", CHARACTER, 32);  //add a column called name to the table customer
    tab->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 files
    create_data_file(*tab); //create the data file of the table customer
    
    return 0;
}

Структура библиотеки

[ редактировать ]

База данных классов

[ редактировать ]

Этот класс хранит имя базы данных и ее таблицы. Основные функции:

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

Полезные функции, использующие базу данных классов:

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

Таблица классов

[ редактировать ]

Этот класс хранит имя таблицы и ее структуру, столбцы таблицы. Основные функции:

   char *name(); //get the table name
   char *name(char *dbname); //set the table name
   void add_col(column &c); //add a new column to the table
   void add_col(char *col_name, char col_type, int col_len=1, char pkey=0);
   column *get_col(int idx); //get the column by its index
   column *get_col(char *name); //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

Полезные функции, использующие таблицу классов:

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

Строка класса

[ редактировать ]

Этот класс хранит столбцы таблицы и данные, которые будут храниться в файле данных. Основные функции:

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

Полезные функции, использующие строку класса:

   void write(table &t, row &r, int idx); //write the data in the data file of the table
   void read(table &t, row &r, int idx); //read the data from the data file of the table
   void del(char *file, table &t, int idx); //delete the data from the data file of the table

Хранилище классов

[ редактировать ]

Этот класс хранит столбец и значение для этого столбца. Основные функции:

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

Полезные функции, использующие хранилище классов:

   int get_int(storage &s); //get the integer being stored
   char get_char(storage &s); //get the char being stored
   bool get_bool(storage &s); //get the bool being stored
   float get_float(storage &s); //get the float being stored
   double get_double(storage &s); //get the double being stored

Столбец класса

[ редактировать ]

Этот класс хранит имя и структуру столбца. Основные функции:

   char *name(); //get the name of the column
   char *name(char *n); //set the name of the column
   char type(); //get the type of the column
   char type(char t); //set the type of the column
   int length(); //get the length of the array that the column can hold
   int length(int len); //set the length of the array that the column can hold, len>0
   void pkey(char b); //set if the column is the primary key or not (0 is false, 1 is true)
   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

Индекс класса

[ редактировать ]

Этот класс хранит индексы таблицы. Основные функции:

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

Полезные функции, использующие индекс класса:

   void write(table &t, index &idx); //write the indexes of a table into a file
   void read(index &idx); //read the indexes from a file

Интерфейс командной строки DBL

[ редактировать ]

С помощью программы интерфейса командной строки DBL можно создать базу данных, таблицу и добавить столбцы в эту таблицу, помимо других операций, таких как печать.

[ редактировать ]
Arc.Ask3.Ru: конец переведенного документа.
Arc.Ask3.Ru
Номер скриншота №: 2be3329af2f1310fe3fa32ac8ea70e8e__1683983400
URL1:https://arc.ask3.ru/arc/aa/2b/8e/2be3329af2f1310fe3fa32ac8ea70e8e.html
Заголовок, (Title) документа по адресу, URL1:
Database Management Library - Wikipedia
Данный printscreen веб страницы (снимок веб страницы, скриншот веб страницы), визуально-программная копия документа расположенного по адресу URL1 и сохраненная в файл, имеет: квалифицированную, усовершенствованную (подтверждены: метки времени, валидность сертификата), открепленную ЭЦП (приложена к данному файлу), что может быть использовано для подтверждения содержания и факта существования документа в этот момент времени. Права на данный скриншот принадлежат администрации Ask3.ru, использование в качестве доказательства только с письменного разрешения правообладателя скриншота. Администрация Ask3.ru не несет ответственности за информацию размещенную на данном скриншоте. Права на прочие зарегистрированные элементы любого права, изображенные на снимках принадлежат их владельцам. Качество перевода предоставляется как есть. Любые претензии, иски не могут быть предъявлены. Если вы не согласны с любым пунктом перечисленным выше, вы не можете использовать данный сайт и информация размещенную на нем (сайте/странице), немедленно покиньте данный сайт. В случае нарушения любого пункта перечисленного выше, штраф 55! (Пятьдесят пять факториал, Денежную единицу (имеющую самостоятельную стоимость) можете выбрать самостоятельно, выплаичвается товарами в течение 7 дней с момента нарушения.)