Skip to content

Database Engine that supports Creating tables, Inserting, Deleting, Updating tuples, Selecting from table, and Creating Index

Notifications You must be signed in to change notification settings

YehiaFarghaly/database-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database-Engine

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)

Java CI with Maven

Apache Maven badge Github Actions badge Junit 5 badge Git badge Github badge Dependabot badge Checkstyle badge Java badge ANTLR badge

Tools


How to run tests and checks:

  • 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

Code examples

Normal Selection

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);

Selection Using SQL

StringBuffer command = new StringBuffer("SELECT * FROM Students WHERE gpa = 4.0 AND id > 100");
engine.parseSQL(command);

Normal Insertion

Hashtable<String, Object> htblColNameValue = new Hashtable<>();
htblColNameValue.put("id", 1);
htblColNameValue.put("name", "student1");
htblColNameValue.put("gpa", 3.3);
engine.insertIntoTable("Students", htblColNameValue);

Insertion Using SQL

StringBuffer command = new StringBuffer("INSERT INTO Students(id, gpa, name) VALUES(1, 3.3, 'student1')");
		engine.parseSQL(command);

Normal Deletion

Hashtable<String, Object> htblColNameValue = new Hashtable<>();
htblColNameValue.put("gpa", 3.3);
engine.DeleteFromTable("Students", htblColNameValue);

Deletion Using SQL

StringBuffer command = new StringBuffer("DELETE FROM  Students WHERE gpa = 3.3");
		engine.parseSQL(command);

Project Structure

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

Run Locally

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

Notes

  • There is a ready table called student with the following columns (ID: int, GPA: Double, Name: String)

Screenshots

Selection Example

Screenshot (130)

Insertion Example

Screenshot (131)

Deletion Example

Screenshot (132)

License

MIT License

Authors