diff --git a/Relation.h b/Relation.h index c41db03..6850ce0 100644 --- a/Relation.h +++ b/Relation.h @@ -7,41 +7,65 @@ 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 + string name; //the name of the relation (table) + vector att; + vector attributeNames; public: - Relation(); + //Relation(); - //constructor - Relation(string n, vector< Attribute > a) { + void initializeRelation(string n, vector attNames, vector a) + { + attributeNames = attNames; name = n; att = a; - } + } void addTuple(vector< string > 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].values[j]).assign(tuple[i]); + + 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]); } } } - void displayTableName() { - cout << "The table name is: " << name << endl; - } - vector< Attribute > getAttributes(){ - return att; + void projectQuery(string input) + { + cout << "-----------Initiated Query Projection---------" << endl; + for(int i = 0; i < att.size(); i++) { + if(att[i].getName() == input) { + + cout << "Column Title: " << input << endl; + for(int j = 0; j < att[i].getSize(); j++) { + cout << att[i].values[j] << endl; + } + + break; + } + else + cout << "Attribute input not valid" << endl; + } } + + void display() + { + cout<<"\n\nDisplay of relation--------------------------------"<