49 lines
873 B
C++
49 lines
873 B
C++
#include <iostream>
|
|
#include <vector>
|
|
#include "Attribute.h"
|
|
|
|
using namespace std;
|
|
|
|
//NOT DONE
|
|
class Relation {
|
|
//a table with rows and columns
|
|
string name; //the name of the relation (table)
|
|
vector<Attribute> att;
|
|
vector<string> attributeNames;
|
|
|
|
public:
|
|
//Relation();
|
|
|
|
void initializeRelation(string n, vector<string> attNames, vector<Attribute> a)
|
|
{
|
|
attributeNames = attNames;
|
|
name = n;
|
|
att = a;
|
|
}
|
|
|
|
void addTuple(vector<string> tuple)
|
|
{
|
|
else
|
|
{
|
|
for(int i = 0; i < att.size(); ++i) //for all the attributes
|
|
{
|
|
att[i].pushBack(tuple[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
void display()
|
|
{
|
|
cout<<"\n\nDisplay of relation--------------------------------"<<endl;
|
|
cout<<"Relation name: "<<name<<endl;
|
|
for (int i = 0; i < attributeNames.size(); ++i)
|
|
{
|
|
|
|
cout<<"\nAttribute name: "<<attributeNames[i]<<": ";
|
|
|
|
att[i].display();
|
|
|
|
}
|
|
|
|
}
|
|
};
|