light weight Database. Created using c++ for every type of machine. Scalable as well as easy to use Database.
- You can watch the video of how to use ourdb database on ourdb youtube channel.
- here is the link :- click here
- you can check ourdb_database/syntax.txt where you can find all updated syntax.
-
Light weight (size less than 2mb)
-
scalable
-
Can run cross platform (Windows ,Mac ,Linux)
-
Dynamically made database. Any developer can easily made changes
-
Files with own encryption and own extension .Ourdb
-
Even low end device like Arduino , raspberry pi can also run it.
-
It requires minimum c++ 17 standard compiler or above to run on any system
-
It is combination (NoSQL + SQL) because it doesn’t have schema for storing table but it has perfect syntax for creating query like SQL
Clone the project
git clone https://github.com/zeelsheladiya/OurDB-Database.git
-> Add Database to your project
- Add or include OurDB_Database.h in your colnsole or gui program file
#include "OurDB_Database.h"
- First step to enter in the database system is to create database. A physical storage area where all table resides.
- Syntax : create/make database/db <database_name>
create database zeel
- Even you can change the (create) keyword in the code(instruction for developer) its dynamic add or remove keyword etc.
- select the database among the existing databases else returns the error.
- Syntax : select/choose database/db <database_name>
- After creating database you have to compulsory select the database in order to create table and perform some action/operations.
select database zeel
- database is so flexible that developer can change any keyword.
- Creates table in the database along with the column in it.
- Syntax : create/make table <table_name> @ <column1_name> <column2_name>…
- After creating database you have to compulsory select the database in order to create table and perform some action/operations.
create table mark @ id name age
- with this simple syntax we can easily create the table in database.
- it will show the selected database/the database you are in right now.
- Syntax : current/present database/db
current database
- this query used when you don’t know what database you are in right now.
- It will rename the database in the system.
- first you have to select the database then and then you can perform rename query.and after renaming you have to again select the database to perform the operation.
- Syntax : rename database <database_name>
select database parth
rename database parthx
- we have given this facility who wants to change the name of the database but it is not good practice to do so..
- It will show all the database resides in the system.
- Syntax : show/display/view all db/database
show all db
- it is advisable to run query prior to any other query so that you can see all the database exists in the system
- It will show all the tables resides in the selected database.
- first we have to select the database so that we can see the table resides in it.
- Syntax : show/display/view all table
show all table
- It will list out all the column which is present in the table
- After selecting database , create table and then you will be able to use this feature.
- Syntax : show all col @ <table_name>
show all col @ tb1
- show column in table never return null value because column in the table decide at the creation of table.
- This command will rename the table exist in the particular database.
- make sure that table must exist before renaming the table.
- Syntax : rename table <old_table_name> <new_table_name>
reaname table tbn tb1
- This command will rename the column in the particular table
- make sure to check that column exist in the table by show all column @ table.
- Syntax :rename column/col from <table_name> @ <old_col_name> <new_col_name>
rename col from tb1 @ age agex
- this feature looks so simple but most important while working with the database.
- Insert query is used to enter the data in the empty column which was created with the table during creation of table
- make sure in which table you are going to insert the data ,that must be created before insertion of data.
- insert or add both will be accepted but not simultaneously.
- Syntax : insert into <table_name> @ '<col1_value>' '<col2_value>' ...
insert into mark @ '1' 'zeel' '20'
- you can see the data in the table by select command we will look for it later on.
- Single quote is necessary for inserting the value in to the table.
- This command will add a new column in the existing table.
- make sure in which table you are going to insert the column ,that must be created before insertion of column.
- insert or add both will be accepted but not simultaneously.
- Syntax : insert/add col/column into <table_name> @ <col_name>
insert col into mark @ gender
- It used to update a data in to the table.
- Here after where table field and value connected with the = operator. Or !(not equal) operator.
- And for more than one condition you can concatenation condition with either &(and) or |(or)
- It's also support < , > , <= , >= operators.
- Syntax : update @ <table_name> set/put <table_field> '<field_value>' where <table_field1>(=|!)<field_value1> & <table_field2>(=|!)<field_value2>
update @ mark set gender 'female' where id=1 & name=zeel
- It will delete the database from the system.
- delete or destroy both are accepted but not simultaneously
- Syntax : delete/destroy database <database_name>
delete db dbn
- Before deleting the database always make sure that your all the tables are deleted or you may loss important data.
- Delete the table from the database.
- make sure to select the database before deleting table.
- Syntax : delete table <table_name>
delete table tb
- Delete the data from the table at particular row/rows.
- make sure to select the database before deleting table.
- Here at particular row/rows you can delete a data.
- Here after where table field and value connected with the = operator. Or !(not equal) operator.
- And for more than one condition you can concatenation condition with either &(and) or |(or)
- It's also support < , > , <= , >= operators.
- Syntax : delete/destroy @ <table_name> where <column_name> (=/!) <column_value> (&/|) <column_name1> (=/!) <column_value1>
delete @ tb1 where id=4
- This will delete the column from the table.
- make sure in which table you are going to insert the column ,that must be created before insertion of column.
- Syntax : delete/destroy column/col from <table_name> @ <col_name>
delete col from tb1 @ pass
- It will select and display the the data into the table format.
- Syntax : select/choose col1 col2 @ <table_name> where <column_name> (=/!) <column_value> (&/|) <column_name1> (=/!) <column_value1>
select * @ tb
- Now ourdb has schema such as primary key nad foreign key.
- Syntax [primary key] : set $ <col_name> @ <table_name>
- Syntax [foreign key] : set # <col_name> @ <table_name> $ <primary_table_name>
// to set primary key
set $ id @ testTable
// to set foreign key
set # id @ testTable $ mainTable
- there are mainly three functions to get better formatted output such as output as a string , map , json.
- Syntax [ output as a table string for console app ] : To_StringTable(run_query("your query"))
- Syntax [ output as a map object ] : To_Map(run_query("your query"))
- Syntax [ output as a json object ] : To_Json(run_query("your query"))
// to get table string
To_StringTable(run_query("select * @ testTable"))
// to get map object
To_Map(run_query("select * @ testTable"))
// to get json object
To_Json(run_query("select * @ testTable"))
- this example's code also can be seen in OurDB_Database/console.cpp.
#include "OurDB_Database.h"
#include <iostream>
#include <string>
#include "variables/query_variables.h"
#include "global_functions/global_function.h"
#include "global_functions/SyntaxCheckerForResultString.h"
using namespace std;
template<class Element, class Container>
bool selectChecker(const Element & s ,const Container & s1)
{
for(string i : s1)
{
//cout << i << endl << s.find(i) << endl;
if(s.find(i) != -1)
{
return true;
}
}
return false;
}
int main() {
string s;
while(true) {
cout << "Enter Your query : ";
getline(cin, s);
if(selectChecker(s,select_db_query))
{
if(selectChecker(s,colSymbol))
{
string check = run_query(s);
if(SyntaxCheckerForResultString(check))
{
cout << endl << To_StringTable(run_query(s)) << endl;
}
else
cout << endl << run_query(s) << endl;
}
else
{
cout << endl << run_query(s) << endl;
}
}
else
{
cout << endl << run_query(s) << endl;
}
}
return 0;
}
- If you need any help regarding this project feel free to contact us on our social media link and github account.
- If you want to contribite in this then read contribution.txt