working on update & delete
This commit is contained in:
parent
c7c701a169
commit
909df70f2d
2 changed files with 29 additions and 18 deletions
17
DBEngine.cpp
17
DBEngine.cpp
|
@ -290,10 +290,21 @@ Relation DBEngine::crossProduct(Relation r1, Relation r2){
|
||||||
//SET Party = ‘Independent’
|
//SET Party = ‘Independent’
|
||||||
//WHERE Name = ‘Joseph Lieberman’
|
//WHERE Name = ‘Joseph Lieberman’
|
||||||
|
|
||||||
Relation DBEngine::update(Relation r, string attNameSet, string attSet, string attNameWhere, string attWhere){
|
Relation DBEngine::updateCmd(Relation r, string attNameSet, string attSet, string attNameWhere, string attWhere){
|
||||||
Relation temp = equality(attNameWhere, attWhere, r);
|
Relation temp = selection(attNameWhere, attWhere, r);
|
||||||
|
vector<Attribute> atts = temp.getAttributes();
|
||||||
|
|
||||||
|
for (int i = 0; i < atts.size(); ++i){
|
||||||
|
if (atts[i].getName() == attNameSet) {
|
||||||
|
for (int j = 0; j < atts[i].getSize(); ++j){
|
||||||
|
atts[i]setValue(attSet, j);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
//currently returns a relation with just the changed values, need to look at proper join
|
||||||
|
//if proper join does not work, plan B is brute force
|
||||||
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,6 @@ public:
|
||||||
Relation setUnion(Relation r1, Relation r2);
|
Relation setUnion(Relation r1, Relation r2);
|
||||||
Relation setDiff(Relation r1, Relation r2);
|
Relation setDiff(Relation r1, Relation r2);
|
||||||
Relation crossProduct(Relation r1, Relation r2);
|
Relation crossProduct(Relation r1, Relation r2);
|
||||||
Relation update(Relation r, string attNameSet, string attSet, string attNameWhere, string attWhere);
|
Relation updateCmd(Relation r, string attNameSet, string attSet, string attNameWhere, string attWhere);
|
||||||
//Relation deleteCmd();
|
//Relation deleteCmd();
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue