Database Engine that supports some features like:
- Creating a table
- Inserting into a table
- Updating a table
- Deleting from a table
- Selecting from a table
- Creating an Index -using Octree-
- Writing SQL queries
- Supported data types: int (java.lang.Integer), double (java.lang.Double), date (java.util.Date), varchar (java.lang.String)
- Language used is Java
- Project is built using maven
- CI pipeline using Github Actions
- Tests are written in Junit5
- Style is preserved using checkStyle
- SQL is parsed using ANTLR
- Make sure to have Apache Maven installed on your pc.
- To run checkStyle checks run the following command :
mvn checkstyle:check
- To run Junit5 tests run the following command :
mvn test
SQLTerm[] sqlTerms = new SQLTerm[2];
sqlTerms[0] = new SQLTerm("Students", "gpa", "=", 4.0);
sqlTerms[1] = new SQLTerm("Students", "id", ">", 100);
String[] strArrOperator = new String[] { "AND" };
engine.selectFromTable(sqlTerms, strArrOperator);
StringBuffer command = new StringBuffer("SELECT * FROM Students WHERE gpa = 4.0 AND id > 100");
engine.parseSQL(command);
Hashtable<String, Object> htblColNameValue = new Hashtable<>();
htblColNameValue.put("id", 1);
htblColNameValue.put("name", "student1");
htblColNameValue.put("gpa", 3.3);
engine.insertIntoTable("Students", htblColNameValue);
StringBuffer command = new StringBuffer("INSERT INTO Students(id, gpa, name) VALUES(1, 3.3, 'student1')");
engine.parseSQL(command);
Hashtable<String, Object> htblColNameValue = new Hashtable<>();
htblColNameValue.put("gpa", 3.3);
engine.DeleteFromTable("Students", htblColNameValue);
StringBuffer command = new StringBuffer("DELETE FROM Students WHERE gpa = 3.3");
engine.parseSQL(command);
Expand
- project-name/
|- src/
|- main/
|- java/
|- app/
|- Action.java
|- DBApp.java
|- IDatabase.java
|- constants/
|- Constants.java
|- datamanipulation/
|- CsvReader.java
|- CsvWriter.java
|- exceptions/
|- DBAppException.java
|- sql/
|- SQLTerm.java
|- antlrfiles/
|- SQLiteLexer.java
|- SQLiteParser.java
|- SQLiteParserBaseListener.java
|- SQLiteParserBaseVisitor.java
|- SQLiteParserListener.java
|- SQLiteParserVisitor.java
|- SQLiteLexer.interp
|- SQLiteLexer.tokens
|- SQLiteParser.interp
|- SQLiteParser.tokens
|- parser/
|- MiniDBListener.java
|- SQLParser.java
|- storage/
|- Cell.java
|- Table.java
|- Page.java
|- Tuple.java
|- TupleBuilder.java
|- TupleDirector.java
|- ITupleBuilder.java
|- ITupleDirector.java
|- index/
|- DBAppNull.java
|- Item.java
|- Vector3.java
|- OctreeIndex.java
|- OctreeNode.java
|- OctreeBounds.java
|- util/
|- Compare.java
|- PagePrinter.java
|- TypeParser.java
|- filecontroller/
|- ConfigReader.java
|- FileCreator.java
|- FileDeleter.java
|- FileType.java
|- Serializer.java
|- search/
|- PageSearch.java
|- TupleSearch.java
|- Selector.java
|- validation/
|- Validator.java
|- test/
|- java/
|- app/
|- DBAppTest.java
1- Clone the project
git clone https://github.com/YehiaFarghaly/Database-Engine.git
2- Go to the project directory
3- Build the project using Maven
mvn clean
4- Run Javafx project using Maven
mvn javafx:run
- There is a ready table called student with the following columns (ID: int, GPA: Double, Name: String)