diff --git a/Attribute.h b/Attribute.h index 9d53d4c..2c51e1b 100755 --- a/Attribute.h +++ b/Attribute.h @@ -9,25 +9,36 @@ using namespace std; class Attribute { //a named column of a relation string name; - - bool isKey; + string type; + bool key; int size; public: vector values; - - void initializeAttribute(string n, vector a){ - + + Attribute(string n, string t, bool k){ name = n; - values = a; + type = t; + key = k; + size = 0; + } + + void addRow(string v) { + values.push_back(v); } string getName(){ return name; } - Attribute(){ } + string getType(){ + return type; + } + + bool isKey(){ + return key; + } void display() { diff --git a/Relation.h b/Relation.h index c41db03..568f020 100755 --- a/Relation.h +++ b/Relation.h @@ -6,21 +6,19 @@ using namespace std; //NOT DONE class Relation { - //a table with rows and columns string name; //The title the user gives it - vector< Attribute > att; //A vector of the columns + vector att; //A vector of the columns public: Relation(); //constructor - Relation(string n, vector< Attribute > a) { + Relation(string n, vector a) { name = n; att = a; - } + } void addTuple(vector< string > tuple) { - //Loop through the attribute columns for(int i = 0; i < att.size(); i++) { @@ -28,11 +26,15 @@ public: for(int j = 0; j < att[i].values.size(); j++){ //In this column, at this element's spot, assign an element from the tuple vector to this spot - (att[i].values[j]).assign(tuple[i]); + att[i].addRow(tuple[i]); } } } + string getTableName() { + return name; + } + void displayTableName() { cout << "The table name is: " << name << endl; } diff --git a/a.out b/a.out new file mode 100755 index 0000000..d8082f0 Binary files /dev/null and b/a.out differ diff --git a/test.cpp b/test.cpp index b6b03b0..03a58ce 100755 --- a/test.cpp +++ b/test.cpp @@ -5,40 +5,26 @@ using namespace std; -int main() { +int main() { + Attribute atributo("shamWow", "VARCHAR(10)", false); - /* - DBEngine engine; - Relation r; - Attribute a; - */ + atributo.addRow("rag"); + atributo.addRow("sponge"); + atributo.addRow("wooow"); + atributo.addRow("cloth"); - vector shamWow; - shamWow.push_back("rag"); - shamWow.push_back("sponge"); - shamWow.push_back("wooow"); - shamWow.push_back("cloth"); - - Attribute atributo; - atributo.initializeAttribute("atributo",shamWow); atributo.display(); - vector doom; - doom.push_back("zombieman"); - doom.push_back("revenant"); - doom.push_back("imp"); - doom.push_back("archvile"); + Attribute atributo2("doom", "VARCHAR(20)", false); + + atributo2.addRow("zombieman"); + atributo2.addRow("revenant"); + atributo2.addRow("imp"); + atributo2.addRow("archvile"); - Attribute atributo2; - atributo2.initializeAttribute("attribute_2", doom); atributo2.display(); - - - string line1 = "Table_1"; - - //Relation r(line1, my_attributes); }