From 91ae6e305ad99640e7f7ab430a77ae5ecf38cb64 Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 15 Sep 2015 18:56:40 -0500 Subject: [PATCH 01/12] Create Attribute.h --- Attribute.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Attribute.h diff --git a/Attribute.h b/Attribute.h new file mode 100644 index 0000000..87b2c25 --- /dev/null +++ b/Attribute.h @@ -0,0 +1,58 @@ +#include +#include + +using namespace std; + +//Funtional, might need more functionality + +//template +class Attribute { + //a named column of a relation + string name; + vector values; + bool isKey; + int size; + +public: + + void initializeAttribute(string n, vector a){ + + name = n; + values = a; + } + + string getName(){ + return name; + } + + Attribute(){ } + + void display() + { + cout<<"Atribute name:\t"< v){ + this.values = v; + } + + Attribute(const Attribute& a){ + this.values = a.getAll(); + } + + Attribute& operator=(const Attribute& a){ + this.values = a.getAll(); + } + + + + vector getAll(){ + return this.values; + } +*/ +}; From 163270d71a8ceceaa595f84264e9bb813c88fd37 Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 15 Sep 2015 18:59:58 -0500 Subject: [PATCH 02/12] Create test2.cpp --- test2.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test2.cpp diff --git a/test2.cpp b/test2.cpp new file mode 100644 index 0000000..5b0a6f8 --- /dev/null +++ b/test2.cpp @@ -0,0 +1,26 @@ +#include +//#include "DBEngine.h" +#include +#include "Attribute.h" + +using namespace std; + +int main() { + + /* + DBEngine engine; + Relation r; + Attribute a; + */ + + vector shamWow; + pendejo.push_back("rag"); + pendejo.push_back("sponge"); + pendejo.push_back("wooow"); + pendejo.push_back("cloth"); + + Attribute atributo; + atributo.initializeAttribute("atributo",shamWow); + + atributo.display(); +} From 0dba891839ed0880f8d16f875f16306d0fd86cc3 Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 15 Sep 2015 19:11:46 -0500 Subject: [PATCH 03/12] Update test2.cpp --- test2.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test2.cpp b/test2.cpp index 5b0a6f8..280656a 100644 --- a/test2.cpp +++ b/test2.cpp @@ -14,10 +14,10 @@ int main() { */ vector shamWow; - pendejo.push_back("rag"); - pendejo.push_back("sponge"); - pendejo.push_back("wooow"); - pendejo.push_back("cloth"); + shamWow.push_back("rag"); + shamWow.push_back("sponge"); + shamWow.push_back("wooow"); + shamWow.push_back("cloth"); Attribute atributo; atributo.initializeAttribute("atributo",shamWow); From f748c986fa156e5c33682cb2e87642103e393c00 Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 15 Sep 2015 20:21:19 -0500 Subject: [PATCH 04/12] Update Attribute.h --- Attribute.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Attribute.h b/Attribute.h index 87b2c25..5be40a0 100644 --- a/Attribute.h +++ b/Attribute.h @@ -29,13 +29,18 @@ public: void display() { - cout<<"Atribute name:\t"< v){ this.values = v; From 2b1141bfe7763ced81537203e2c9f15bfe71d958 Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 15 Sep 2015 20:21:50 -0500 Subject: [PATCH 05/12] Update test2.cpp --- test2.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test2.cpp b/test2.cpp index 280656a..2a02bcb 100644 --- a/test2.cpp +++ b/test2.cpp @@ -1,7 +1,8 @@ #include //#include "DBEngine.h" #include -#include "Attribute.h" +//#include "Attribute.h" +#include "Relation.h" using namespace std; @@ -23,4 +24,25 @@ int main() { atributo.initializeAttribute("atributo",shamWow); atributo.display(); + + vector doom; + doom.push_back("zombieman"); + doom.push_back("revenant"); + doom.push_back("imp"); + doom.push_back("archvile"); + + Attribute atributo2; + atributo2.initializeAttribute("atributo2",doom); + + atributo2.display(); + + vector setOfAttributes; + vector attNames; + attNames.push_back("attName1"); + attNames.push_back("attName2"); + + Relation myLittleRelation; + myLittleRelation.initializeRelation("randomName", attNames, setOfAttributes); + + myLittleRelation.display(); } From c052e7cbf09b7922b7d37dafb098c78e70faa847 Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 15 Sep 2015 20:23:47 -0500 Subject: [PATCH 06/12] Create Relation.h --- Relation.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Relation.h diff --git a/Relation.h b/Relation.h new file mode 100644 index 0000000..69ccfea --- /dev/null +++ b/Relation.h @@ -0,0 +1,45 @@ +#include +#include +#include "Attribute.h" + +using namespace std; + +//NOT DONE +class Relation { + //a table with rows and columns + string name; //the name of the relation (table) + vector att; + vector attributeNames; + +public: + //Relation(); + + void initializeRelation(string n, vector attNames, vector a) + { + attributeNames = attNames; + name = n; + att = a; + } + + void addTuple(vector< Attribute> tuple); + + void display() + { + cout<<"\n\nDisplay of relation--------------------------------"< Date: Tue, 15 Sep 2015 20:35:43 -0500 Subject: [PATCH 07/12] Update Attribute.h --- Attribute.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Attribute.h b/Attribute.h index 5be40a0..b57879e 100644 --- a/Attribute.h +++ b/Attribute.h @@ -29,8 +29,8 @@ public: void display() { - cout<<"\nAtribute name:\t"< Date: Tue, 15 Sep 2015 20:36:07 -0500 Subject: [PATCH 08/12] Update test2.cpp --- test2.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test2.cpp b/test2.cpp index 2a02bcb..0167b02 100644 --- a/test2.cpp +++ b/test2.cpp @@ -37,6 +37,9 @@ int main() { atributo2.display(); vector setOfAttributes; + setOfAttributes.push_back(atributo); + setOfAttributes.push_back(atributo2); + vector attNames; attNames.push_back("attName1"); attNames.push_back("attName2"); From b2fa6c1a556167f37e7051581ba25abb0beb523e Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 15 Sep 2015 20:36:33 -0500 Subject: [PATCH 09/12] Update Relation.h --- Relation.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Relation.h b/Relation.h index 69ccfea..8668481 100644 --- a/Relation.h +++ b/Relation.h @@ -32,12 +32,7 @@ public: cout<<"\nAttribute name: "< Date: Tue, 15 Sep 2015 21:03:01 -0500 Subject: [PATCH 10/12] Update Relation.h --- Relation.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Relation.h b/Relation.h index 8668481..6f69bfa 100644 --- a/Relation.h +++ b/Relation.h @@ -21,7 +21,16 @@ public: att = a; } - void addTuple(vector< Attribute> tuple); + void addTuple(vector tuple) + { + else + { + for(int i = 0; i < att.size(); ++i) //for all the attributes + { + att[i].pushBack(tuple[i]); + } + } + } void display() { From 6004fe724f5d771999d1c05bb6e65ea8ba2804ab Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 15 Sep 2015 21:03:35 -0500 Subject: [PATCH 11/12] Update test2.cpp --- test2.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test2.cpp b/test2.cpp index 0167b02..1c23c06 100644 --- a/test2.cpp +++ b/test2.cpp @@ -47,5 +47,14 @@ int main() { Relation myLittleRelation; myLittleRelation.initializeRelation("randomName", attNames, setOfAttributes); + + //adding tuple business----------------------- + + vector tuple; + tuple.push_back("hadoken"); + tuple.push_back("soryuken"); + + myLittleRelation.addTuple(tuple); + myLittleRelation.display(); } From 70e29704301f9c16d5c608ec3a448801b29b5828 Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 15 Sep 2015 21:04:08 -0500 Subject: [PATCH 12/12] Update Attribute.h --- Attribute.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Attribute.h b/Attribute.h index b57879e..92c435b 100644 --- a/Attribute.h +++ b/Attribute.h @@ -41,6 +41,11 @@ public: { return values.size(); } + + void pushBack(string s) + { + values.push_back(s); + } /* Attribute(vector v){ this.values = v;