diff --git a/Attribute.h b/Attribute.h index 2c51e1b..9d8587b 100755 --- a/Attribute.h +++ b/Attribute.h @@ -14,7 +14,6 @@ class Attribute { int size; public: - vector values; Attribute(string n, string t, bool k){ @@ -44,15 +43,15 @@ public: { cout<<"Atribute name:\t"< getElements(){ - return values; + int getSize() + { + return values.size(); } - */ }; diff --git a/DBEngine.cpp b/DBEngine.cpp deleted file mode 100755 index a2842e4..0000000 --- a/DBEngine.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#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 index e889297..b621ed4 100755 --- a/DBEngine.h +++ b/DBEngine.h @@ -3,18 +3,35 @@ #include #include "Relation.h" -using namespace std; - +//still in progress class DBEngine { - vector tables; + vector tables; + int size; public: - DBEngine(); - - void addRelation(Relation r) { + DBEngine(){ + size = 0; + } + + void createTable(string n, vector a) { + Relation r(n, a); tables.push_back(r); } + void createTable(Relation r) { + tables.push_back(r); + } + + void showTable() {} + void saveToFile() { /*???*/ } + void insertTuple() {} + void deleteTuple() {} + void selectTuples() {} + void project() {} + void product() {} + void unionComp() {} + + vector getRelations() { return tables; } diff --git a/Relation.h b/Relation.h index 568f020..b27f6fc 100755 --- a/Relation.h +++ b/Relation.h @@ -2,9 +2,7 @@ #include #include "Attribute.h" -using namespace std; - -//NOT DONE +//Functional class Relation { string name; //The title the user gives it vector att; //A vector of the columns @@ -18,7 +16,7 @@ public: att = a; } - void addTuple(vector< string > tuple) { + void addTuple(vector tuple) { //Loop through the attribute columns for(int i = 0; i < att.size(); i++) { @@ -39,11 +37,24 @@ public: cout << "The table name is: " << name << endl; } - vector< Attribute > getAttributes(){ + vector getAttributes() { return att; } int getSize() { return att.size(); } + + void display() { + cout<<"\n\nDisplay of relation--------------------------------"< -//#include "DBEngine.h" #include -#include "Attribute.h" - -using namespace std; +#include "DBEngine.h" +//still in progress int main() { - Attribute atributo("shamWow", "VARCHAR(10)", false); + DBEngine engine; + + Attribute att1("shamWow", "VARCHAR(10)", true); + att1.addRow("rag"); + att1.addRow("sponge"); + att1.addRow("wooow"); + att1.addRow("cloth"); + att1.display(); - atributo.addRow("rag"); - atributo.addRow("sponge"); - atributo.addRow("wooow"); - atributo.addRow("cloth"); + Attribute att2("doom", "VARCHAR(20)", false); + att2.addRow("zombieman"); + att2.addRow("revenant"); + att2.addRow("imp"); + att2.addRow("archvile"); + att2.display(); - atributo.display(); + vector vec; + vec.push_back(att1); + vec.push_back(att2); - Attribute atributo2("doom", "VARCHAR(20)", false); - - atributo2.addRow("zombieman"); - atributo2.addRow("revenant"); - atributo2.addRow("imp"); - atributo2.addRow("archvile"); - - atributo2.display(); - - string line1 = "Table_1"; - - //Relation r(line1, my_attributes); + engine.createTable("table1", vec); }