git hates me

This commit is contained in:
Rebecca Schofield 2015-09-30 16:48:54 -05:00
parent 18ba9c1112
commit ae67c5b8f6
3 changed files with 13 additions and 67 deletions

View file

@ -227,85 +227,37 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){
Relation new_r = r1; Relation new_r = r1;
new_r.setTableName("TEMP"); new_r.setTableName("TEMP");
vector<string> temp; vector<string> temp;
//bool duplicate = false;
/*
for (int i = 0; i < r1.getAttributes()[0].getSize(); ++i)
{
new_r.removeTuple(0);
}
*/
int size = 0; int size = 0;
//cout << "test1" << endl;
for(int x = 0; x < r2.getAttributes().size(); ++x) for(int x = 0; x < r2.getAttributes().size(); ++x)
{ {
//cout << "test2" << endl;
for (int i = 0; i < r2.getAttributes()[x].getSize(); ++i) for (int i = 0; i < r2.getAttributes()[x].getSize(); ++i)
{ {
//cout << "test3" << endl;
temp = r2.getTuple(i); temp = r2.getTuple(i);
for(int y = 0; y < new_r.getAttributes().size(); ++y) for(int y = 0; y < new_r.getAttributes().size(); ++y)
{ {
size = new_r.getAttributes()[y].getSize(); size = new_r.getAttributes()[y].getSize();
//cout << "test4" << endl;
new_r.getAttributes()[y].getSize(); new_r.getAttributes()[y].getSize();
for (int j = 0; j < size; ++j) for (int j = 0; j < size; ++j)
{ {
//cout << "test5" << endl;
for(int a = 0; a < temp.size(); ++a) for(int a = 0; a < temp.size(); ++a)
{ {
//cout << "test6" << endl;
for(int b = 0; b < new_r.getTuple(j).size(); ++b) 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]) if (temp[a] == new_r.getTuple(j)[b])
{ {
new_r.removeFromTuple(b, j); new_r.removeFromTuple(b, j);
//cout << "test" << endl;
//duplicate = true;
//break;
} }
} }
} }
size = new_r.getAttributes()[y].getSize(); 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; return new_r;
} }
} }

View file

@ -31,5 +31,12 @@ public:
Relation rename(vector<string> newnames, Relation &r); Relation rename(vector<string> newnames, Relation &r);
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();
//UPDATE Senator
//SET Party = Independent
//WHERE Name = Joseph Lieberman;
//Relation deleteCmd();
}; };

View file

@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include "Parser.h" #include "Parser.h"
//#include "Condition.h" #include "Condition.h"
#include "DBEngine.h" #include "DBEngine.h"
using namespace std; using namespace std;
@ -30,25 +30,11 @@ int main () {
engine.createTable("Food", v); engine.createTable("Food", v);
Attribute att4("Dessert", "VARCHAR(20)", true); //engine.update
Attribute att5("Midnight Snack", "VARCHAR(20)", false);
att4.addCell("Ice Cream Sundae"); /*actual testing
att4.addCell("Chocolate Bar");
att5.addCell("Hummus and Carrots");
att5.addCell("Potato Chips");
vector<Attribute> 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();
string x; string x;
cout << "Enter DBMS Commands: "; cout << "Enter DBMS Commands: ";
while(getline(cin, x)) while(getline(cin, x))
{ {
@ -56,4 +42,5 @@ int main () {
parse(x, engine); parse(x, engine);
cout << "Enter DBMS Commands: "; cout << "Enter DBMS Commands: ";
} }
*/
} }