rename fixed and insert attributes add

This commit is contained in:
Rebecca Schofield 2015-09-23 16:34:15 -05:00
parent 32fbf439f8
commit e7037e5909
9 changed files with 46 additions and 25 deletions

29
Condition.cpp Executable file
View file

@ -0,0 +1,29 @@
#include <iostream>
#include "Attribute.h"
using namespace std;
//currently only implementing for comparison
void equality(Attribute a, string s){
}
void equality(Attribute a, int i){
}
void gt(Attribute a, int i){
}
void lt(Attribute a, int i){
}
void gte(Attribute a, int i){
}
void lte(Attribute a, int i){
}

View file

@ -3,11 +3,11 @@
using namespace std;
class Condition{
Attribute att;
public:
//currently only implemented for comparison
Condition(Attribute a);
Condition(Attribute a);
};
//currently only implementing for comparison
Condition();
void equality(Attribute a, string s);
void equality(Attribute a, int i);
void gt(Attribute a, int i);
void lt(Attribute a, int i);
void gte(Attribute a, int i);
void lte(Attribute a, int i);

View file

@ -62,12 +62,12 @@ Relation DBEngine::projection(vector<string> input, Relation r){
//test error matching
void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newnames){
if (oldnames.size() != newnames.size()) {
cout << "Failure to rename: number of attributes do not match.";
cout << "FAILURE TO RENAME: number of attributes do not match.\n";
return;
}
else if (oldnames != r.getAttributeNames()) {
cout << "Failure to rename: the attributes to be renamed do not exist in the relation.";
cout << "FAILURE TO RENAME: the attributes to be renamed do not exist in the relation.\n";
return;
}

BIN
DevelopmentLog.pdf Executable file

Binary file not shown.

BIN
Parser.zip Executable file

Binary file not shown.

View file

@ -13,6 +13,12 @@ Relation::Relation(string n, vector<Attribute> a){
size = a.size();
}
void Relation::insertAttributes(vector<Attribute> a){
for (int i = 0; i < a.size(); ++i){
att.push_back(a[i]);
}
}
string Relation::getTableName(){
return name;
}

View file

@ -10,6 +10,7 @@ class Relation{
public:
Relation(string n);
Relation(string n, vector<Attribute> a);
void insertAttributes(vector<Attribute> a);
string getTableName();
vector<Attribute> getAttributes();
vector<string> getAttributeNames();

BIN
a.out

Binary file not shown.

View file

@ -50,22 +50,7 @@ int main() {
newa.push_back("Hcnul");
newa.push_back("Rennid");
<<<<<<< HEAD
//Projection test
vector<string> projectTest;
projectTest.push_back("Breakfast");
projectTest.push_back("Dinner");
cout << "\n***Initiated Projection***\n" << endl;
Relation sub_r = engine.projection(projectTest, r);
sub_r.display();
//engine.rename(r, o, n);
}
=======
engine.rename(engine.getTableFromName("Food"), old, newa);
engine.getTableFromName("Food").display();
cout << "finished";
}
>>>>>>> master