fixed a thing
This commit is contained in:
parent
3983003035
commit
091f084b45
3 changed files with 6 additions and 38 deletions
|
@ -85,7 +85,7 @@ void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newna
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Relation DBEngine::setUnion(Relation r1, Relation r2){
|
Relation DBEngine::setUnion(Relation r1, Relation r2){
|
||||||
if (r1.getAttributeNames() != r2.getAttributeNames()){
|
if (r1.getAttributeNames() != r2.getAttributeNames()){
|
||||||
cout << "Failure to union: the relations are not union-compatible";
|
cout << "Failure to union: the relations are not union-compatible";
|
||||||
return;
|
return;
|
||||||
|
@ -102,17 +102,17 @@ void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newna
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < new_atts.size(); ++i) {
|
/*for (int i = 0; i < new_atts.size(); ++i) {
|
||||||
for (int j = 0; j < new_atts.size(); ++j){
|
for (int j = 0; j < new_atts.size(); ++j){
|
||||||
if (new_atts[i] == new_atts[j]){
|
if (new_atts[i] == new_atts[j]){
|
||||||
new_atts.erase(new_atts.begin() + i);
|
new_atts.erase(new_atts.begin() + i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//currently all returned relations are called TEMP
|
//currently all returned relations are called TEMP
|
||||||
Relation new_r("TEMP", new_atts);
|
Relation new_r("TEMP", new_atts);
|
||||||
return new_r;
|
return new_r;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
Relation selection(string attName, string s, Relation r);
|
Relation selection(string attName, string s, Relation r);
|
||||||
Relation projection(vector<string> input, Relation r);
|
Relation projection(vector<string> input, Relation r);
|
||||||
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
||||||
//Relation setUnion(Relation r1, Relation r2);
|
Relation setUnion(Relation r1, Relation r2);
|
||||||
//void setDiff();
|
//void setDiff();
|
||||||
//void crossProduct();
|
//void crossProduct();
|
||||||
};
|
};
|
||||||
|
|
32
test.cpp
32
test.cpp
|
@ -28,31 +28,6 @@ int main() {
|
||||||
v.push_back(att3);
|
v.push_back(att3);
|
||||||
|
|
||||||
engine.createTable("Food", v);
|
engine.createTable("Food", v);
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
vector<string> tuple;
|
|
||||||
tuple.push_back("Omelette");
|
|
||||||
tuple.push_back("Fried Rice");
|
|
||||||
tuple.push_back("Grouper");
|
|
||||||
|
|
||||||
engine.getTableFromName("Food").insertTuple(tuple);
|
|
||||||
|
|
||||||
vector<string> old;
|
|
||||||
vector<string> newa;
|
|
||||||
|
|
||||||
old.push_back("Breakfast");
|
|
||||||
old.push_back("Lunch");
|
|
||||||
old.push_back("Dinner");
|
|
||||||
|
|
||||||
newa.push_back("Tsafkaerb");
|
|
||||||
newa.push_back("Hcnul");
|
|
||||||
newa.push_back("Rennid");
|
|
||||||
|
|
||||||
engine.rename(engine.getTableFromName("Food"), old, newa);
|
|
||||||
engine.getTableFromName("Food").display();
|
|
||||||
cout << "finished";
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
|
|
||||||
Attribute att4("SecondBreakfast", "VARCHAR(20)", true);
|
Attribute att4("SecondBreakfast", "VARCHAR(20)", true);
|
||||||
Attribute att5("SecondLunch", "VARCHAR(20)", false);
|
Attribute att5("SecondLunch", "VARCHAR(20)", false);
|
||||||
|
@ -75,12 +50,5 @@ int main() {
|
||||||
|
|
||||||
engine.createTable("MoarFood", v2);
|
engine.createTable("MoarFood", v2);
|
||||||
|
|
||||||
vector<string> test = engine.getTableFromName("Food").getTuple(1);
|
|
||||||
|
|
||||||
for (int i = 0; i < test.size(); ++i){
|
|
||||||
cout << test[i] << " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
//engine.setUnion(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display();
|
//engine.setUnion(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display();
|
||||||
}
|
}
|
||||||
>>>>>>> beccadev
|
|
||||||
|
|
Reference in a new issue