A mini sql engine which will run a subset of SQL queries using command line interface.
- csv files for tables.
- If a file is : File1.csv , the table name would be File1
- There will be no tab separation or space separation.
- Both csv file type cases taken care of : the one where values are in double quotes and the one where values are without quotes.
- All the elements in files would be only INTEGERS
- A file named: metadata.txt (note the extension) would be available which will have the following structure for each table: -<begin_table> -<table_name> - -.... - -<end_table> Check the file metadata.txt in files for better understanding.
- Column names are unique among all the tables. So column names are not preceded by table names in SQL queries.
- Project Columns(could be any number of columns) from one or more tables :
- Usage : Select * from table_name;
- Usage : Select col1, col2 from table_name;
- Aggregate functions: Simple aggregate functions on a single column. Sum, average, max, min and count :
- Usage : Select max(col1) from table_name;
- Select/project with distinct from one table: (distinct of a pair of values indicates the pair should be distinct), Usage : Select distinct col1, col2 from table_name;
- Select with WHERE from one or more tables :
- Usage : Select col1,col2 from table1,table2 where col1 = 10 AND col2 = 20;
- In the where queries, there would be a maximum of one AND/OR operator with no NOT operators.
- Relational operators include "< , >, <=, >=, =".
- Select/Project Columns(could be any number of columns) from table using “group by”:
- Usage : Select col1, COUNT(col2) from table_name group by col1.
- In the group by queries, Sum/Average/Max/Min/Count can be used as aggregate functions.
- Select/Project Columns(could be any number of columns) from table in ascending/descending order according to a column using “order by”:
- Usage : Select col1,col2 from table_name order by col1 ASC|DESC.
- At max only one column can be used to sort the rows.
- Query can have multiple tables in it.
- Multiple error handling checks are put to deal with erroneous queries.
- To run the engine, use : bash runSQL.sh "Query"; where Query can be all the permutations and combinations of SQL that MySQL permits using the built clauses.