diff --git a/Attribute.h b/Attribute.h new file mode 100755 index 0000000..2c1bd3d --- /dev/null +++ b/Attribute.h @@ -0,0 +1,37 @@ +#include +#include + +using namespace std; + +//Funtional, might need more functionality + +template +class Attribute { + //a named column of a relation + string name; + vector values; + bool isKey; + int size; +public: + Attribute(){ } + + Attribute(vector v){ + this.values = v; + } + + Attribute(const Attribute& a){ + this.values = a.getAll(); + } + + Attribute& operator=(const Attribute& a){ + this.values = a.getAll(); + } + + string getName(){ + return name; + } + + vector getAll(){ + return this.values; + } +}; \ No newline at end of file diff --git a/DBEngine.cpp b/DBEngine.cpp new file mode 100755 index 0000000..a2842e4 --- /dev/null +++ b/DBEngine.cpp @@ -0,0 +1,57 @@ +#include "DBEngine.h" + +using namespace std; + +DBEngine::DBEngine(){ + // +} + +//create a new table in memory +void DBEngine::createCmd(){ + // +} + +//open a txt file, parse SQL script, load data in table +//void DBEngine::openCmd(){ + // +//} + +//should write cmdList to a .txt file +void DBEngine::saveCmd(){ + // +} + +//display the database +void DBEngine::showCmd(){ + // +} + +//add a tuple to a table in the memory +void DBEngine::insertQuery(){ + // +} + +//remove a tuple from a table in the memory +void DBEngine::deleteQuery(){ + // +} + +//search and return one more tuples from a table in the memory +void DBEngine::selectQuery(){ + // +} + +//return a subset of attributes (columns) +void DBEngine::projectQuery(){ + // +} + +//each row in the first table is paired with all the rows in the second table +void DBEngine::productQuery(){ + // +} + +//true if relations have the same # of attributes and each attribute must be from the same domain +bool DBEngine::unionComp(){ + return false; +} diff --git a/db_engine.h b/DBEngine.h similarity index 63% rename from db_engine.h rename to DBEngine.h index ba2ea28..9ec458b 100755 --- a/db_engine.h +++ b/DBEngine.h @@ -1,12 +1,17 @@ #include #include #include +#include "Relation.h" -class db_engine { - std::vector cmdList; +using namespace std; + +class DBEngine { + //member variables + //NOT DONE + //vector tables; public: - db_engine(); + DBEngine(); void createCmd(); //void openCmd(); void saveCmd(); diff --git a/Relation.h b/Relation.h new file mode 100755 index 0000000..222b8a5 --- /dev/null +++ b/Relation.h @@ -0,0 +1,16 @@ +#include +#include +#include "Attribute.h" + +using namespace std; + +//NOT DONE +class Relation { + //a table with rows and columns + string name; + vector< Attribute > att; +public: + Relation(); + Relation(vector< Attribute > a) { att = a; } + void addTuple(vector< Attribute > tuple); +}; \ No newline at end of file diff --git a/db_engine.cpp b/db_engine.cpp deleted file mode 100755 index 10abbbf..0000000 --- a/db_engine.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "db_engine.h" - -db_engine::db_engine(){ - // -} - -//create a new table in memory -//creates a vector -void db_engine::createCmd(){ - // -} - -//open a txt file, parse SQL script, load data in table -//void db_engine::openCmd(){ - // -//} - -//should write cmdList to a .txt file -void db_engine::saveCmd(){ - std::ofstream dbCmdFile; - dbCmdFile.open("dbCmds.txt", std::ios_base::app); - - std::vector::iterator it = cmdList.begin(); - while (it != cmdList.end()){ - dbCmdFile << *it << "\n"; - ++it; - } - - cmdList.clear(); -} - -//display the table currently stored in memory -void db_engine::showCmd(){ - // -} - -//add a tuple to a table in the memory -void db_engine::insertQuery(){ - // -} - -//remove a tuple from a table in the memory -void db_engine::deleteQuery(){ - // -} - -//search and return one more tuples from a table in the memory -void db_engine::selectQuery(){ - // -} - -//return a subset of attributes (columns) -void db_engine::projectQuery(){ - // -} - -//each row in the first table is paired with all the rows in the second table -void db_engine::productQuery(){ - // -} - -//true if relations have the same # of attributes and each attribute must be from the same domain -bool db_engine::unionComp(){ - return false; -} diff --git a/test.cpp b/test.cpp index 37541d8..a419a4a 100755 --- a/test.cpp +++ b/test.cpp @@ -1,8 +1,10 @@ #include -#include "db_engine.h" +#include "DBEngine.h" + +using namespace std; int main() { - db_engine engine; - engine.saveCmd(); - std::cout << "succesfully traversed the code!"; -} \ No newline at end of file + DBEngine engine; + Relation r; + Attribute a; +}