diff --git a/DBEngine.cpp b/DBEngine.cpp index 208da05..5d67824 100755 --- a/DBEngine.cpp +++ b/DBEngine.cpp @@ -185,8 +185,10 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){ Relation DBEngine::crossProduct(Relation r1, Relation r2){ vector new_atts = r1.getAttributes(); + int r1_attsize = r1.getAttributes()[0].getSize(); + int r2_attsize = r2.getAttributes()[0].getSize(); - for (int i = 0; i < r2.getAttributes().size(); ++i) { + for (int i = 0; i < r2_attsize; ++i) { new_atts.push_back(r2.getAttributes()[i]); } @@ -194,6 +196,29 @@ Relation DBEngine::crossProduct(Relation r1, Relation r2){ new_atts[i].clearAllValues(); } + vector r1_tuple; + vector r2_tuple; + + for (int i = 0; i < r1_attsize; ++i) { + r1_tuple = r1.getTuple(i); + + for (int a = 0; a < r1_tuple.size(); ++a) { + cout << r1_tuple[a] << " "; + } + + for (int j = 0; j < r2_attsize; ++j) { + r2_tuple = r2.getTuple(j); + + for (int b = 0; b < r2_tuple.size(); ++b){ + cout << r2_tuple[b] << " "; + } + + cout << "\n"; + } + + cout << "\n\n"; + } + //currently all returned relations are called TEMP Relation new_r("TEMP", new_atts); diff --git a/DevelopmentLog.pdf b/DevelopmentLog.pdf deleted file mode 100755 index 6d6db27..0000000 Binary files a/DevelopmentLog.pdf and /dev/null differ diff --git a/OUTPUT.txt b/OUTPUT.txt deleted file mode 100755 index 09bc7f9..0000000 --- a/OUTPUT.txt +++ /dev/null @@ -1,82 +0,0 @@ ---------------- -Queries ---------------- - -Selection: - -correct: select ( age == 12 ) people ; -incorrect: select ( age ))))) people ; - -Projection: - -correct: project ( age ) people ; -incorrect: project age people ; - -Renaming: - -correct: rename ( age, years old ) ; -incorrect: rename age years ; - -Set Union: - -correct: union ( people + animals ) ; -incorrect: union people animals ; - -Set Difference: - -correct: difference ( people - animals ) ; -incorrect: difference people animals ; - -Cross Product: - -correct: product ( people * animals ) ; -incorrect: product people animals ; - -------------------- -Commands -------------------- - -Open: - -correct: OPEN people ; -incorrect: OPEN ; - -Close: - -correct: CLOSE people ; -incorrect: CLOSE ; - -Save: - -correct: SAVE people ; -incorrect: SAVE ; - -Exit: - -correct: EXIT ; -incorrect: EXIT people ; - -Show: - -correct: SHOW people ; -incorrect: SHOW ; - -Create: - -correct: CREATE TABLE people ( age INTEGER, name VARCHAR ( 20 ) ) PRIMARY KEY ( name ) ; -incorrect: CREATE TABLE people age name ; - -Update: - -correct: UPDATE people SET ( age = 10 ) WHERE ( name == "Bob" ) ; -incorrect: UPDATE ( age = 10 ) WHERE people ; - -Insert: - -correct: INSERT INTO people VALUES FROM ( 12, "Benny" ) ; -incorrect: INSERT INTO people 12 "Benny" ; - -Delete: - -correct: DELETE FROM people WHERE ( name == "John" ) ; -incorrect: DELETE IN people WHEN (name=John) ; diff --git a/a.out b/a.out deleted file mode 100755 index 5ff8697..0000000 Binary files a/a.out and /dev/null differ diff --git a/test b/test deleted file mode 100755 index bb0df00..0000000 Binary files a/test and /dev/null differ diff --git a/test.cpp b/test.cpp index 1d6a304..10fb8fd 100755 --- a/test.cpp +++ b/test.cpp @@ -43,5 +43,6 @@ int main() { engine.createTable("MoarFood", v2); - engine.crossProduct(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display(); + engine.crossProduct(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")); + //engine.crossProduct(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display(); }