11# Database-Engine
2- Database Engine that supports some operations like:
2+ Database Engine that supports some features like:
33- Creating a table
44- Inserting into a table
55- Updating a table
66- Deleting from a table
77- Selecting from a table
88- Creating an Index -using Octree-
9- - Writing SQL queries
9+ - Writing SQL queries
10+ - Supported data types: ** int** (java.lang.Integer), ** double** (java.lang.Double), ** date** (java.util.Date), ** varchar** (java.lang.String)
1011</br >
1112
1213[ ![ Java CI with Maven] ( https://github.com/YehiaFarghaly/Database-Engine/actions/workflows/maven.yml/badge.svg )] ( https://github.com/YehiaFarghaly/Database-Engine/actions/workflows/maven.yml )
@@ -17,21 +18,30 @@ Database Engine that supports some operations like:
1718 <img src =" https://img.shields.io/badge/Git--%23F05032?style=for-the-badge&logo=Git " alt =" Git badge " >
1819 <img src =" https://img.shields.io/badge/-Github-%23181717?style=for-the-badge&logo=Github " alt =" Github badge " >
1920 <img src =" https://img.shields.io/badge/-Dependabot-%23025E8C?style=for-the-badge&logo=Dependabot " alt =" Dependabot badge " >
20- </a >
21- <a href =" https://checkstyle.org/ " target =" _blank " >
22- <img src =" https://img.shields.io/badge/Checkstyle-8.43-blue?style=for-the-badge&logo=checkstyle " alt =" Checkstyle badge " >
23- </a >
21+ <img src =" https://img.shields.io/badge/-Checkstyle-%234c6ef5?style=for-the-badge&logo=Checkstyle&logoColor=white " alt =" Checkstyle badge " >
22+ <img src =" https://img.shields.io/badge/-Java-%23ED8B00?style=for-the-badge&logo=java&logoColor=white " alt =" Java badge " >
23+ <img src = " https://img.shields.io/badge/-ANTLR-%237231d6?style=for-the-badge&logo=ANTLR&logoColor=white " alt = " ANTLR badge " >
2424</div >
2525
2626---
2727## Tools
2828- Language used is [ Java] ( https://www.java.com/en/ )
2929- Project is built using [ maven] ( https://maven.apache.org/ )
30- - CI pipelines using [ Github Actions] ( https://github.com/features/actions )
30+ - CI pipeline using [ Github Actions] ( https://github.com/features/actions )
3131- Tests are written in [ Junit5] ( https://junit.org/junit5/ )
3232- Style is preserved using [ checkStyle] ( https://checkstyle.sourceforge.io/ )
3333- SQL is parsed using [ ANTLR] ( https://www.antlr.org/ )
34+
35+ ---
36+ ## How to run tests and checks:
37+ * Make sure to have [ Apache Maven] ( https://maven.apache.org/ ) installed on your pc.
38+ * To run checkStyle checks run the following command : ` mvn checkstyle:check `
39+ * To run Junit5 tests run the following command : ` mvn test `
40+
41+ ---
42+
3443## Code examples
44+
3545### Normal Selection
3646``` java
3747SQLTerm [] sqlTerms = new SQLTerm [2 ];
@@ -41,11 +51,120 @@ String[] strArrOperator = new String[] { "AND" };
4151engine. selectFromTable(sqlTerms, strArrOperator);
4252```
4353### Selection Using SQL
44- ```
45- StringBuffer command = new StringBuffer("SELECT * FROM Students WHERE gpa = 4.0 AND id = 100");
54+ ``` java
55+ StringBuffer command = new StringBuffer (" SELECT * FROM Students WHERE gpa = 4.0 AND id > 100" );
4656engine. parseSQL(command);
4757```
48- ## Running Application
58+ ---
59+
60+ ### Normal Insertion
61+ ``` java
62+ Hashtable<String , Object > htblColNameValue = new Hashtable<> ();
63+ htblColNameValue. put(" id" , 1 );
64+ htblColNameValue. put(" name" , " student1" );
65+ htblColNameValue. put(" gpa" , 3.3 );
66+ engine. insertIntoTable(" Students" , htblColNameValue);
67+ ```
68+ ### Insertion Using SQL
69+ ``` java
70+ StringBuffer command = new StringBuffer (" INSERT INTO Students(id, gpa, name) VALUES (1, 3.3, \' student1\' )" );
71+ engine. parseSQL(command);
72+ ```
73+ ---
74+
75+ ### Normal Deletion
76+ ``` java
77+ Hashtable<String , Object > htblColNameValue = new Hashtable<> ();
78+ htblColNameValue. put(" gpa" , 3.3 );
79+ engine. DeleteFromTable (" Students" , htblColNameValue);
80+ ```
81+ ### Deletion Using SQL
82+ ``` java
83+ StringBuffer command = new StringBuffer (" DELETE FROM Students WHERE gpa = 3.3" );
84+ engine. parseSQL(command);
85+ ```
86+ ---
87+ ## Project Structure
88+ <details >
89+ <summary >Expand</summary >
90+
91+ ``` mathematica
92+ - project-name/
93+ |- src/
94+ |- main/
95+ |- java/
96+ |- app/
97+ |- Action.java
98+ |- DBApp.java
99+ |- IDatabase.java
100+ |- constants/
101+ |- Constants.java
102+ |- datamanipulation/
103+ |- CsvReader.java
104+ |- CsvWriter.java
105+ |- exceptions/
106+ |- DBAppException.java
107+ |- sql/
108+ |- SQLTerm.java
109+ |- antlrfiles/
110+ |- SQLiteLexer.java
111+ |- SQLiteParser.java
112+ |- SQLiteParserBaseListener.java
113+ |- SQLiteParserBaseVisitor.java
114+ |- SQLiteParserListener.java
115+ |- SQLiteParserVisitor.java
116+ |- SQLiteLexer.interp
117+ |- SQLiteLexer.tokens
118+ |- SQLiteParser.interp
119+ |- SQLiteParser.tokens
120+ |- parser/
121+ |- MiniDBListener.java
122+ |- SQLParser.java
123+ |- storage/
124+ |- Cell.java
125+ |- Table.java
126+ |- Page.java
127+ |- Tuple.java
128+ |- TupleBuilder.java
129+ |- TupleDirector.java
130+ |- ITupleBuilder.java
131+ |- ITupleDirector.java
132+ |- index/
133+ |- DBAppNull.java
134+ |- Item.java
135+ |- Vector3.java
136+ |- OctreeIndex.java
137+ |- OctreeNode.java
138+ |- OctreeBounds.java
139+ |- util/
140+ |- Compare.java
141+ |- PagePrinter.java
142+ |- TypeParser.java
143+ |- filecontroller/
144+ |- ConfigReader.java
145+ |- FileCreator.java
146+ |- FileDeleter.java
147+ |- FileType.java
148+ |- Serializer.java
149+ |- search/
150+ |- PageSearch.java
151+ |- TupleSearch.java
152+ |- Selector.java
153+ |- validation/
154+ |- Validator.java
155+ |- test/
156+ |- java/
157+ |- app/
158+ |- DBAppTest.java
159+
160+ ```
161+ </details >
162+
49163
50164## Authors
165+ - [ Yehia Mohamed] ( https://github.com/YehiaFarghaly )
166+ - [ Malek Mohamed] ( https://github.com/malekelkssas )
167+ - [ Mohamed Khaled] ( https://github.com/Mohamed-Khaled308 )
168+ - [ Abdelrahman Elmeky] ( https://github.com/Aelmeky )
169+ - [ Abdulrahman Fahmy] ( https://github.com/abdulrhman500 )
51170
0 commit comments