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
2015-09-17 17:14:28 -05:00

54 lines
1.1 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
int size;
public:
Relation(string n) {
name = n;
size = 0;
}
Relation(string n, vector<Attribute> a) {
name = n;
att = a;
size = a.size();
}
//addAttribute
string getTableName() { return name; }
vector<Attribute> getAttributes() { return att; }
int getSize() { return size; }
//assumes that all attribute titles are unique
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].getValues()[j] << endl;
}
break;
}
else
cout << "Attribute input not valid" << endl;
}
}
void display() {
cout << "--------------------------\n";
cout << name << "\n";
for (int i = 0; i < att.size(); ++i){
att[i].display();
}
cout << "--------------------------\n";
}
};