git hates me
This commit is contained in:
parent
18ba9c1112
commit
ae67c5b8f6
3 changed files with 13 additions and 67 deletions
48
DBEngine.cpp
48
DBEngine.cpp
|
@ -227,85 +227,37 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){
|
|||
Relation new_r = r1;
|
||||
new_r.setTableName("TEMP");
|
||||
vector<string> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,5 +31,12 @@ public:
|
|||
Relation rename(vector<string> 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();
|
||||
};
|
||||
|
|
23
test.cpp
23
test.cpp
|
@ -1,7 +1,7 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
#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<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();
|
||||
/*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: ";
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
Reference in a new issue