diff --git a/Relation.h b/Relation.h index b27f6fc..18a79f1 100755 --- a/Relation.h +++ b/Relation.h @@ -4,57 +4,82 @@ //Functional class Relation { - string name; //The title the user gives it - vector att; //A vector of the columns + //a table with rows and columns + string name; //the name of the relation (table) + vector att; + vector attributeNames; public: - Relation(); + //Relation(); - //constructor - Relation(string n, vector a) { + void initializeRelation(string n, vector attNames, vector a) + { + attributeNames = attNames; name = n; att = a; } - void addTuple(vector tuple) { - //Loop through the attribute columns - for(int i = 0; i < att.size(); i++) { - - //Loop through the elements in the i'th column - 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].addRow(tuple[i]); + void addTuple(vector< string > tuple) { + + + if(tuple.size() != att.size()){ + cout << "\n ERROR" << endl; + } + else { + //Loop through the attribute columns + for(int i = 0; i < att.size(); i++) { + att[i].pushBack(tuple[i]); } } } - string getTableName() { - return name; + void removeTuple(int tupleNum) + { + if (tupleNum > att[0].getSize() || tupleNum < 0) + { + cout<<"ERROR! index out of bound"< getAttributes() { - return att; - } - - int getSize() { - return att.size(); - } - - void display() { + + void display() + { cout<<"\n\nDisplay of relation--------------------------------"<