From ae67c5b8f6b31dc03707400f40a4301d284b9c16 Mon Sep 17 00:00:00 2001 From: Rebecca Schofield Date: Wed, 30 Sep 2015 16:48:54 -0500 Subject: [PATCH] git hates me --- DBEngine.cpp | 48 ------------------------------------------------ DBEngine.h | 9 ++++++++- test.cpp | 23 +++++------------------ 3 files changed, 13 insertions(+), 67 deletions(-) diff --git a/DBEngine.cpp b/DBEngine.cpp index 32a06ef..d86d1b5 100755 --- a/DBEngine.cpp +++ b/DBEngine.cpp @@ -227,85 +227,37 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){ Relation new_r = r1; new_r.setTableName("TEMP"); vector temp; - //bool duplicate = false; - /* - for (int i = 0; i < r1.getAttributes()[0].getSize(); ++i) - { - new_r.removeTuple(0); - } - */ int size = 0; - //cout << "test1" << endl; - for(int x = 0; x < r2.getAttributes().size(); ++x) { - - //cout << "test2" << endl; for (int i = 0; i < r2.getAttributes()[x].getSize(); ++i) { - - //cout << "test3" << endl; temp = r2.getTuple(i); for(int y = 0; y < new_r.getAttributes().size(); ++y) { size = new_r.getAttributes()[y].getSize(); - //cout << "test4" << endl; new_r.getAttributes()[y].getSize(); for (int j = 0; j < size; ++j) { - //cout << "test5" << endl; for(int a = 0; a < temp.size(); ++a) { - //cout << "test6" << endl; for(int b = 0; b < new_r.getTuple(j).size(); ++b) { - //cout << "test7" << endl; - //cout << temp[a] << " " << new_r.getTuple(j)[b] << " " << b << endl; if (temp[a] == new_r.getTuple(j)[b]) { new_r.removeFromTuple(b, j); - //cout << "test" << endl; - //duplicate = true; - //break; } } } size = new_r.getAttributes()[y].getSize(); } - /* - if (!duplicate) - { - new_r.insertTuple(temp); - } - */ - //duplicate = false; } } } - //make this one for loop later! - /* - for (int i = 0; i < r2.getAttributes()[0].getSize(); ++i) { - temp = r2.getTuple(i); - - for (int j = 0; j < r1.getAttributes()[0].getSize(); ++j){ - if (temp == r1.getTuple(j)){ - duplicate = true; - break; - } - } - - if (!duplicate){ - new_r.insertTuple(temp); - } - - duplicate = false; - } - */ - return new_r; } } diff --git a/DBEngine.h b/DBEngine.h index 81009d3..7916e96 100755 --- a/DBEngine.h +++ b/DBEngine.h @@ -31,5 +31,12 @@ public: Relation rename(vector newnames, Relation &r); Relation setUnion(Relation r1, Relation r2); Relation setDiff(Relation r1, Relation r2); - Relation crossProduct(Relation r1, Relation r2); + Relation crossProduct(Relation r1, Relation r2); + Relation update(); + + //UPDATE Senator + //SET Party = ‘Independent’ + //WHERE Name = ‘Joseph Lieberman’; + + //Relation deleteCmd(); }; diff --git a/test.cpp b/test.cpp index 710b098..82732f7 100755 --- a/test.cpp +++ b/test.cpp @@ -1,7 +1,7 @@ #include #include #include "Parser.h" -//#include "Condition.h" +#include "Condition.h" #include "DBEngine.h" using namespace std; @@ -30,25 +30,11 @@ int main () { engine.createTable("Food", v); - Attribute att4("Dessert", "VARCHAR(20)", true); - Attribute att5("Midnight Snack", "VARCHAR(20)", false); + //engine.update - att4.addCell("Ice Cream Sundae"); - att4.addCell("Chocolate Bar"); - att5.addCell("Hummus and Carrots"); - att5.addCell("Potato Chips"); - - vector v2; - v2.push_back(att4); - v2.push_back(att5); - - engine.createTable("MoarFood", v2); - - //engine.getTableFromName("Food").display(); - //engine.getTableFromName("MoarFood").display(); - - engine.crossProduct(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display(); + /*actual testing string x; + cout << "Enter DBMS Commands: "; while(getline(cin, x)) { @@ -56,4 +42,5 @@ int main () { parse(x, engine); cout << "Enter DBMS Commands: "; } + */ }