diff --git a/db_engine.cpp b/db_engine.cpp deleted file mode 100755 index d4060eb..0000000 --- a/db_engine.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "db_engine.h" - -using namespace std; - -db_engine::db_engine(){ - // -} - -//create a new table in memory -//creates a vector -//DONE -void db_engine::createCmd(string tableName, vector attributes, vector pkeys){ - //creates the proper command and adds it to the cmdList - //make this better, we need a heterogenous container - string output = ""; - output += "CREATE TABLE " + tableName + " ("; - - vector::iterator it = attributes.begin(); - while (it != attributes.end()){ - if (it == attributes.begin()) - if ((it + 1) != attributes.end()) - output += *it + ","; - else - output += *it; - else - output+= " " + *it; - - ++it; - } - - output += ") PRIMARY KEY ("; - - vector::iterator it2 = pkeys.begin(); - while (it2 != pkeys.end()){ - if (it2 == pkeys.begin()) - if ((it2 + 1) != pkeys.end()) - output += *it2 + ","; - else - output += *it2; - else - output+= " " + *it2; - - ++it2; - } - - output += ");"; - - cmdList.push_back(output); -} - -//open a txt file, parse SQL script, load data in table -//void db_engine::openCmd(){ - // -//} - -//should write cmdList to a .txt file -//DONE -void db_engine::saveCmd(){ - ofstream dbCmdFile; - dbCmdFile.open("dbCmds.txt", ios_base::app); - - vector::iterator it = cmdList.begin(); - while (it != cmdList.end()){ - dbCmdFile << *it << "\n"; - ++it; - } - - cmdList.clear(); -} - -//display the database -//DONE -void db_engine::showCmd(string tableName){ - cmdList.push_back("SHOW " + tableName + ""); -} - -//add a tuple to a table in the memory -//maybe make a table object? -//BECCA -void db_engine::insertQuery(string tableName, vector t){ - string output = "INSERT INTO " + tableName + " VALUES FROM ("; - - vector::iterator it = t.begin(); - while (it != t.end()){ - if (it == t.begin()) - if ((it + 1) != t.end()) - output += *it + ","; - else - output += *it; - else - output+= " " + *it; - - ++it; - } - - cmdList.push_back(output + ");"); -} - -//remove a tuple from a table in the memory -//BECCA -void db_engine::deleteQuery(){ - // -} - -//search and return one more tuples from a table in the memory -//WILLIAM -void db_engine::selectQuery(){ - // -} - -//return a subset of attributes (columns) -//BRANDON -void db_engine::projectQuery(){ - // -} - -//each row in the first table is paired with all the rows in the second table -//BRANDON -void db_engine::productQuery(){ - // -} - -//true if relations have the same # of attributes and each attribute must be from the same domain -//WILLIAM -bool db_engine::unionComp(){ - return false; -} diff --git a/db_engine.h b/db_engine.h deleted file mode 100755 index e56f754..0000000 --- a/db_engine.h +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include - -using namespace std; - -class db_engine { - vector cmdList; - //vector> table; - -public: - db_engine(); - void createCmd(string tableName, vector attributes, vector pkeys); - //void openCmd(); - void saveCmd(); - void showCmd(string tableName); - void insertQuery(string tableName, vector t); - void deleteQuery(); - void selectQuery(); - void projectQuery(); - void productQuery(); - bool unionComp(); -};