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/DBEngine.h b/DBEngine.h new file mode 100755 index 0000000..9ec458b --- /dev/null +++ b/DBEngine.h @@ -0,0 +1,25 @@ +#include +#include +#include +#include "Relation.h" + +using namespace std; + +class DBEngine { + //member variables + //NOT DONE + //vector tables; + +public: + DBEngine(); + void createCmd(); + //void openCmd(); + void saveCmd(); + void showCmd(); + void insertQuery(); + void deleteQuery(); + void selectQuery(); + void projectQuery(); + void productQuery(); + bool unionComp(); +}; 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/test.cpp b/test.cpp index 392549b..a419a4a 100755 --- a/test.cpp +++ b/test.cpp @@ -1,26 +1,10 @@ #include -#include "db_engine.h" +#include "DBEngine.h" using namespace std; int main() { - db_engine engine; - - vector attributes; - vector pkeys; - //we need a better way to do this - //going for function right now - attributes.push_back("username VARCHAR(20)"); - attributes.push_back("password VARCHAR(20)"); - pkeys.push_back("password"); - - engine.createCmd("users", attributes, pkeys); - - vector tuple; - tuple.push_back("csce315"); - tuple.push_back("12345"); - - engine.insertQuery("users", tuple); - - engine.saveCmd(); + DBEngine engine; + Relation r; + Attribute a; }