This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
dmspine64backup/Relation.h
Rebecca Schofield 992157c88d fixed my stuff
2015-09-15 22:08:18 -05:00

65 lines
No EOL
1.2 KiB
C++
Executable file

#include <iostream>
#include <vector>
#include "Attribute.h"
//Functional
class Relation {
string name; //The title the user gives it
vector<Attribute> att; //A vector of the columns
itn size;
public:
Relation();
//constructor
Relation(string n, vector<Attribute> a) {
name = n;
att = a;
size = 0;
}
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].addRow(tuple[i]);
size++;
}
}
}
int getSize() { return size; }
string getTableName() {
return name;
}
void displayTableName() {
cout << "The table name is: " << name << endl;
}
vector<Attribute> getAttributes() {
return att;
}
int getSize() {
return att.size();
}
void display() {
cout<<"\n\nDisplay of relation--------------------------------"<<endl;
cout<<"Relation name: "<<name<<endl;
for (int i = 0; i < att.size(); ++i)
{
cout<<"\nAttribute name: "<<att[i].getName()<<": ";
att[i].display();
}
}
};