
OurDB Database
light weight Database. Created using c++ for every type of machine. Scalable as well as easy to use Database.
Authors
đź”— Social Media Links
Documentation
Video Tutorial
- You can watch the video of how to use ourdb database on ourdb youtube channel.
- here is the link :- click here
Other Syantax related help
- you can check ourdb_database/syntax.txt where you can find all updated syntax.
Features
-
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
Run Locally
Clone the project
git clone https://github.com/zeelsheladiya/OurDB-Database.git
Usage/Examples
-> Add Database to your project
- Add or include OurDB_Database.h in your colnsole or gui program file
#include "OurDB_Database.h"
How To Use OurDB Database
Create database:
- 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
create database zeel

- Even you can change the (create) keyword in the code(instruction for developer) its dynamic add or remove keyword etc.
Select database:
- select the database among the existing databases else returns the error.
- Syntax : select/choose database/db
- 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.
Create Table:
- Creates table in the database along with the column in it.
- Syntax : create/make table
@ … - 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.
Current 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.
Rename database:
- 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
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..
Show databases:
- 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
Show tables:
- 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

Show column in 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 @
show all col @ tb1

- show column in table never return null value because column in the table decide at the creation of table.
Rename table in database:
- This command will rename the table exist in the particular database.
- make sure that table must exist before renaming the table.
- Syntax : rename table
reaname table tbn tb1

Rename column in table:
- 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
@
rename col from tb1 @ age agex

- this feature looks so simple but most important while working with the database.
Insert data in to the table:
- 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
@ ' ' ' ' ...
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.
Adding new column in 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
@
insert col into mark @ gender

Updating a data in to the table:
- 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 @
set/put ' ' where (=|!) & (=|!)
update @ mark set gender 'female' where id=1 & name=zeel

Delete the database:
- It will delete the database from the system.
- delete or destroy both are accepted but not simultaneously
- Syntax : delete/destroy database
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:
- Delete the table from the database.
- make sure to select the database before deleting table.
- Syntax : delete table
delete table tb

Delete the particular table data:
- 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 @
where (=/!) (&/|) (=/!)
delete @ tb1 where id=4

Delete the column:
- 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
@
delete col from tb1 @ pass

Select data from table:
- It will select and display the the data into the table format.
- Syntax : select/choose col1 col2 @
where (=/!) (&/|) (=/!)
select * @ tb

To set primary and foreign key:
- Now ourdb has schema such as primary key nad foreign key.
- Syntax [primary key] : set $
@ - Syntax [foreign key] : set #
@ $
// to set primary key
set $ id @ testTable
// to set foreign key
set # id @ testTable $ mainTable
Functions for output:
- 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"))
Other updates will be added after new commits...
Examples of console app with ourdb database
- 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;
}
Contact
- If you need any help regarding this project feel free to contact us on our social media link and github account.
Contribution
- If you want to contribite in this then read contribution.txt