Remember, the project is to be submitted 24 hours before the final presentation date and time. Late submissions will lose 10%

 

Here is the link to our final project

 

sample batch file

Here is the expected output

Final Presentation:

During the scheduled time, you will present your final project and your Multimap class as described below:
You must appear on the date and time discussed in class and present your project personally (or via Zoom if so instructed) This is a requirement. 

Purpose:

Program implements a database that responds to sql-like commands:

 

Grammar:

 

<CREATE | MAKE> : {  <create | make> table <TABLE_NAME> fields <FIELD_NAME> [, <FIELD_NAME>...]  }
<INSERT> : { insert <INTO> <TABLE_NAME> values <VALUE> [, <VALUE>...]      }
<SELECT> : {  select <* | FIELD_NAME> [, ,FIELD_NAME>...]
					from <TABLE_NAME>
					where <FIELD_NAME> <RELATIONAL_OPERATOR> <VALUE>
						[<LOGICAL_OPERATOR>
							<FIELD_NAME> <RELATIONAL_OPERATOR> <VALUE>...]
			}

<VALUE>  : A string of alphanumeric characters, or a string of alphanumeric
 			characters and spaces enclosed by double quotation marks:
 			"Jean Luise", Finch, 1923
<RELATIONAL OPERATOR> : [ = | > | < | >= | <= ]
<LOGICAL OPERATOR>    : [and | or]

 

 

Data Structure:

 

Program uses Maps and Multimaps based on B+Trees as the primary data structure:

Individual indices, list of indices, list of keywords etc.

Program uses binary files for disk storage of database record data

Program uses text files for storing names of fields, tables, number of records and other information that needs to be remembered from session to session.

Program uses a state machine (an adjacency matrix implementation of a graph) representing the grammar for command line interpretation.

table Class:

 

The table class manages a single table’s field list and data. it will provide methods for creating new tables, retrieving an existing table and responding to select queries.

 

SQL Class

 

the SQL class manages all the tables that has been created in this system (this includes previous sessions). It will provide a command line interface to allow the user to issue sql commands (create, insert and select)

 

Batch Processing:

 

The SQL class will also provide a batch mode: Constructor will take a file name (a text file) as argument an will execute these commands within:

 

 

create table student fields last, first, major

insert into student values Yang, Bo, “Computer Science”
insert into student values Davis, John, Math
insert into student values Johnson, “Mary Ann”, “Biology”
create table employee fields lname, fname, dept, hireyear
insert into employee values Jackson, David, Finance, 2016
insert into employee values Davidson, “Mary Alice”, complaints, 2012

 

You will be given a file to test your program for submission and for presentation.

Output: batch processing:

//****************************************************************************
//		LOGICAL OPERATORS
//****************************************************************************


//.................
//:OR AND         :
//.................
[104] select * from student where fname = Flo or major = CS and age <= 23

Table name: _select_table_343, records: 3
 record          fname          lname          major            age        company

      0            Flo            Yao             CS             20         Google
      1            Flo        Jackson           Math             21         Google
      2     Anna Grace        Del Rio             CS             22           USAF




SQL: DONE.
[105] select * from employee where last = "Van Gogh" or last = Jackson and salary >= 165000

Table name: _select_table_347, records: 5
 record           last          first            dep         salary           year

      0        Jackson            Flo           Math         165000           2017
      1        Jackson          Billy           Math         170000           2017
      2       Van Gogh        Vincent            Art         240000           2015
      3       Van Gogh        Vincent             CS         245000           2015
      4       Van Gogh        Jim Bob        Phys Ed         230000           2010

Consider the example above:
  1. There are lines of text in the batch file that begin with two slashes: // These lines must be printed back to the screen and otherwise ignored by your SQL class.
  2. Number your queries starting from zero.
  3. Print the query back to the screen as seen above.
  4. output of the select statement must contain the table name (temporary table) and the number of records. This is done in the Table's insertion operator.
  5. output of the select statements must contain the record headings as seen above.
  6. make sure the output prints in columns.
  7. Each record is numbered starting from zero. These are not the record numbers in the original table, but the record numbers in the resulting table.

 

 

B+ Tree demonstration

Create a project that includes all the files for your B+Tree to function properly. Write a test function that adds numbers 1 through 200 into a B+Tree with MIN set at 1.

You will demonstrate the remove function and a few other functionalities of your class.

 

Map and Multimap Classes:

 

They are both based on a B+Tree that  you designed. The only standard library (or code not written by you) used in this program is the string and vector classes.

Your map and multi map will implement and your program will use the functions detailed in your “Map and Multimap Classes” assignment.

 

Multimap Presentation:

Create a new project and include all the files necessary to run your FTokenizer and your Multimap classes. Use the code provided as your main.cpp. Test your project with solitude.txt. You may be supplied with a different text file for the final presentation.

With the exception of the include paths, this code may not be changed.

 

#include <iostream>
#include "../../../includes/tokenize/ftokenizer.h"
#include "../../../includes/bplustree/multimap.h"
#include "../../../includes/bplustree/map.h"
#include <string>

using namespace std;

MMap<string, long> get_word_indices(char* file_name);


int main(int argc, char *argv[])
{
    MMap<string, long> word_indices;
    word_indices = get_word_indices("solitude.txt");
    cout<<endl<<endl<<endl;

    //list all nodes of the index mmap:
    for (MMap<string, long>::Iterator it = word_indices.begin();
         it != word_indices.end(); it++){
        cout<<*it<<endl;
    }


    cout<<endl<<endl<<endl;
    cout<<"---------------------------------------------------"<<endl;
    string this_word = "ice";
    cout<<"---------------------------------------------------"<<endl;
    cout<<"Indices of \""<<this_word<<"\""<<endl;
    //list indices of this_word:
    if (word_indices.contains(this_word)){
        cout<<this_word<<": "<<word_indices[this_word]<<endl;
    }
    cout<<endl<<endl<<endl;

    cout<<"---------------------------------------------------"<<endl;
    string from = "ask";
    string to = "asker";
    //list from .. to:
    cout<<"listing indices from \""<<from<<"\" to \""<<to<<"\""<<endl;
    cout<<"---------------------------------------------------"<<endl;
    for (MMap<string, long>::Iterator it =
                word_indices.lower_bound(from);
         it != word_indices.upper_bound(to) &&
         it != word_indices.end(); it++){
        cout<<*it<<endl;
    }

    cout <<endl<<endl<<endl<< "========== E N D  ====================" << endl;
    return 0;
}


MMap<string, long> get_word_indices(char* file_name){
    const bool debug = false;
    MMap<string, long> word_indices;
    FTokenizer ftk("solitude.txt");
    Token t;
    long count = 0;

    ftk >> t;
    while (ftk.more()){
        //only the "words"
        if (t.type_string() == "ALPHA"){
            string s;
            s = t.token_str();
            word_indices[s] += count;
            count++;
            if (debug)
                cout<<"|"<<t.token_str()<<"|"<<endl;
        }
        ftk >> t;
    }
    return word_indices;
}

 

Your code will be fully documented.