rename fixed and insert attributes add
This commit is contained in:
parent
32fbf439f8
commit
e7037e5909
9 changed files with 46 additions and 25 deletions
29
Condition.cpp
Executable file
29
Condition.cpp
Executable 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){
|
||||||
|
|
||||||
|
}
|
16
Condition.h
16
Condition.h
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class Condition{
|
//currently only implementing for comparison
|
||||||
Attribute att;
|
Condition();
|
||||||
|
void equality(Attribute a, string s);
|
||||||
public:
|
void equality(Attribute a, int i);
|
||||||
//currently only implemented for comparison
|
void gt(Attribute a, int i);
|
||||||
Condition(Attribute a);
|
void lt(Attribute a, int i);
|
||||||
Condition(Attribute a);
|
void gte(Attribute a, int i);
|
||||||
};
|
void lte(Attribute a, int i);
|
|
@ -62,12 +62,12 @@ Relation DBEngine::projection(vector<string> input, Relation r){
|
||||||
//test error matching
|
//test error matching
|
||||||
void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newnames){
|
void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newnames){
|
||||||
if (oldnames.size() != newnames.size()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (oldnames != r.getAttributeNames()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
DevelopmentLog.pdf
Executable file
BIN
DevelopmentLog.pdf
Executable file
Binary file not shown.
BIN
Parser.zip
Executable file
BIN
Parser.zip
Executable file
Binary file not shown.
|
@ -13,6 +13,12 @@ Relation::Relation(string n, vector<Attribute> a){
|
||||||
size = a.size();
|
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(){
|
string Relation::getTableName(){
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ class Relation{
|
||||||
public:
|
public:
|
||||||
Relation(string n);
|
Relation(string n);
|
||||||
Relation(string n, vector<Attribute> a);
|
Relation(string n, vector<Attribute> a);
|
||||||
|
void insertAttributes(vector<Attribute> a);
|
||||||
string getTableName();
|
string getTableName();
|
||||||
vector<Attribute> getAttributes();
|
vector<Attribute> getAttributes();
|
||||||
vector<string> getAttributeNames();
|
vector<string> getAttributeNames();
|
||||||
|
|
BIN
a.out
BIN
a.out
Binary file not shown.
15
test.cpp
15
test.cpp
|
@ -50,22 +50,7 @@ int main() {
|
||||||
newa.push_back("Hcnul");
|
newa.push_back("Hcnul");
|
||||||
newa.push_back("Rennid");
|
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.rename(engine.getTableFromName("Food"), old, newa);
|
||||||
engine.getTableFromName("Food").display();
|
engine.getTableFromName("Food").display();
|
||||||
cout << "finished";
|
cout << "finished";
|
||||||
}
|
}
|
||||||
>>>>>>> master
|
|
||||||
|
|
Reference in a new issue