Re-Updated projection... again.
This commit is contained in:
parent
6f10af0b32
commit
71961f6659
1 changed files with 12 additions and 5 deletions
17
DBEngine.cpp
17
DBEngine.cpp
|
@ -51,12 +51,19 @@ void DBEngine::saveToFile(vector<string> cmds){
|
||||||
//assumes that all attribute titles are unique
|
//assumes that all attribute titles are unique
|
||||||
Relation DBEngine::projection(vector<string> input, Relation r){
|
Relation DBEngine::projection(vector<string> input, Relation r){
|
||||||
|
|
||||||
|
vector<Attribute> v;
|
||||||
|
string new_name = r.getTableName() + " Projection";
|
||||||
|
|
||||||
// for(int i = 0; i < input.size(); i++) {
|
for(int i = 0; i < input.size(); ++i) {
|
||||||
// it = find(r.getAttributes().begin(), r.getAttributes().end(), input[i])
|
|
||||||
|
|
||||||
//if(r[i].getName == input[])
|
for(int j = 0; j < r.getSize(); ++j) {
|
||||||
// }
|
if((r.getAttributes())[j].getName() == input[i])
|
||||||
|
v.push_back((r.getAttributes())[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Relation temp(new_name, v);
|
||||||
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
//test error matching
|
//test error matching
|
||||||
|
@ -76,4 +83,4 @@ void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newna
|
||||||
r.renameAttribute(oldnames[i], newnames[i]);
|
r.renameAttribute(oldnames[i], newnames[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue