diff --git a/DBEngine.cpp b/DBEngine.cpp index d028aea..6101b46 100755 --- a/DBEngine.cpp +++ b/DBEngine.cpp @@ -51,12 +51,19 @@ void DBEngine::saveToFile(vector cmds){ //assumes that all attribute titles are unique Relation DBEngine::projection(vector input, Relation r){ + vector v; + string new_name = r.getTableName() + " Projection"; -// for(int i = 0; i < input.size(); i++) { -// it = find(r.getAttributes().begin(), r.getAttributes().end(), input[i]) + for(int i = 0; i < input.size(); ++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 @@ -76,4 +83,4 @@ void DBEngine::rename(Relation& r, vector oldnames, vector newna r.renameAttribute(oldnames[i], newnames[i]); } } -} \ No newline at end of file +}