Update Relation.h
This commit is contained in:
parent
d4e1e5bc04
commit
6fa6ad2b44
1 changed files with 36 additions and 5 deletions
39
Relation.h
39
Relation.h
|
@ -7,10 +7,41 @@ using namespace std;
|
||||||
//NOT DONE
|
//NOT DONE
|
||||||
class Relation {
|
class Relation {
|
||||||
//a table with rows and columns
|
//a table with rows and columns
|
||||||
string name;
|
string name; //The title the user gives it
|
||||||
vector< Attribute<T> > att;
|
vector< Attribute > att; //A vector of the columns
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Relation();
|
Relation();
|
||||||
Relation(vector< Attribute<T> > a) { att = a; }
|
|
||||||
void addTuple(vector< Attribute<T> > tuple);
|
//constructor
|
||||||
|
Relation(string n, vector< Attribute > a) {
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayTableName() {
|
||||||
|
cout << "The table name is: " << name << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector< Attribute > getAttributes(){
|
||||||
|
return att;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSize() {
|
||||||
|
return att.size();
|
||||||
|
}
|
||||||
};
|
};
|
Reference in a new issue