Database Management Library
| DBL - Database Management Library | |
|---|---|
| Desenvolvedor | ROCHA, Rodrigo C. O. |
| Lançamento estável | 1.0
/ 2 de julho de 2010 |
| Licença | GNU General Public License |
| Website | http://sites.google.com/site/rcorcs/download/library http://sourceforge.net/projects/dblibrary/ |
DBL - Database Management Library é uma biblioteca em linguagem C++ que implementa um Gestor de Banco de dados relacional. A biblioteca DBL source code está sob termos da GNU General Public License.
Design
DBL é uma biblioteca que se torna parte integral do software aplicativo. Diferentemente de um SGBDR client–server que é um processo independente com o qual o aplicativo se comunica. O software aplicativo faz uso das funcionalidades da biblioteca DBL através de subrotina, que reduz a latência de acessos ao banco de dados pois chamadas à funções dentro de um mesmo processo são muito mais eficientes que em uma comunicação entre processos.
Programas de Exemplo
Criando um banco de dados simples
Este e um programa básico que cria um banco de dados simples. Entretanto, por ser uma tarefa que geralmente é realizada apenas uma vez, pode ser feita pelo DBL Command-Line Interface.
#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;
}
Inserindo um registro em uma tabela
Este é um programa basico que insere um novo registro na tabela.
#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
read(db); //load the database structure
table *tab = db.get_tab("customer"); //get the table customer from the database
row r( tab->new_row() ); //get a row with the structure of the table customer
int cod = 31415;
char name[32] = "Charles";
int birthdate[3] = {27, 6, 2010};
char sex = 'm';
int phone = 88123456;
//set the values stored by the row
r.set(0, &cod);
r.set(1, name);
r.set(2, birthdate);
r.set(3, &sex);
r.set(4, &phone);
int i = num_row(*tab); //get the number of rows in the data file
//write the row into the data file of the table customer,
//where i is the index of the new record
write(*tab, r, i );
return 0;
}
DBL Command-Line Interface
Pelo programa DBL Command-Line Interface pode-se criar banco de dados, criar tabelas e adicionar colunas à uma tabela, além de outras operações tais como mostrar na tela a estrutura dos banco de dados e tabelas.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.