diff --git a/DBAppV2.cpp b/DBAppV2.cpp old mode 100644 new mode 100755 diff --git a/DBEngine.cpp b/DBEngine.cpp index 417c7bf..83208e8 100755 --- a/DBEngine.cpp +++ b/DBEngine.cpp @@ -215,6 +215,7 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){ Relation new_r = r1; new_r.setTableName("TEMP"); vector temp; +<<<<<<< HEAD //bool duplicate = false; int size = 0; @@ -226,6 +227,15 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){ for (int i = 0; i < r2.getAttributes()[x].getSize(); ++i) { +======= + + int size = 0; + + for(int x = 0; x < r2.getAttributes().size(); ++x) + { + for (int i = 0; i < r2.getAttributes()[x].getSize(); ++i) + { +>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61 temp = r2.getTuple(i); for(int y = 0; y < new_r.getAttributes().size(); ++y) @@ -248,7 +258,11 @@ Relation DBEngine::setDiff(Relation r1, Relation r2){ } } } +<<<<<<< HEAD } +======= + } +>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61 return new_r; } } @@ -287,4 +301,15 @@ Relation DBEngine::crossProduct(Relation r1, Relation r2){ return new_r; +<<<<<<< HEAD +======= +} + +//UPDATE Senator +//SET Party = ‘Independent’ +//WHERE Name = ‘Joseph Lieberman’ + +Relation DBEngine::update(Relation r, string attNameSet, string attSet, string attNameWhere, string attWhere){ + return r; +>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61 } diff --git a/DBEngine.h b/DBEngine.h index ddbdd13..788bc34 100755 --- a/DBEngine.h +++ b/DBEngine.h @@ -30,5 +30,11 @@ public: Relation rename(vector newnames, Relation &r); Relation setUnion(Relation r1, Relation r2); Relation setDiff(Relation r1, Relation r2); +<<<<<<< HEAD Relation crossProduct(Relation r1, Relation r2); +======= + Relation crossProduct(Relation r1, Relation r2); + Relation update(Relation r, string attNameSet, string attSet, string attNameWhere, string attWhere); + //Relation deleteCmd(); +>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61 }; diff --git a/Parser.cpp b/Parser.cpp old mode 100644 new mode 100755 index c41a61b..0cf3214 --- a/Parser.cpp +++ b/Parser.cpp @@ -581,7 +581,7 @@ tuple, Relation> expression(vector input, DBEngine &engin vector showCMD(vector input, DBEngine &engine) { - if(engine.isRelation(input[0])) + if(engine.isRelation(input[0]) && (input[1] != "+" && input[1] != "-" && input[1] != "*")) { engine.getTableFromName(input[0]).display(); input.erase(input.begin()); @@ -954,6 +954,7 @@ vector updateCMD(vector input, DBEngine &engine) } + // send update command to DBEngine } @@ -967,36 +968,30 @@ vector deleteCMD(vector input, DBEngine &engine) input.erase(input.begin()); input.erase(input.begin()); - PRelation r(input[0]); + Relation rcond = engine.getTableFromName(input[0]); + Relation rfinal = engine.getTableFromName(input[0]); + + input.erase(input.begin()); + + vector s; if(input[0] == "WHERE") { + input.erase(input.begin()); if(input[0] == "(") { - //PCondition c; - - PComparison c; - POperand oops1; - POperand oops2; - POp op; - + input.erase(input.begin()); while(input[0] != ")") { - oops1.setPOperand(input[0]); + s.push_back(input[0]); input.erase(input.begin()); - - oops2.setPOperand(input[0]); - input.erase(input.begin()); - - op.setPOp(input[0]); - input.erase(input.begin()); - - c.setPComparison(oops1.getPOperand(), op.getPOp(), oops2.getPOperand()); } } } + rcond = condition(); // send delete command to DBEngine + } else cout<<"Syntax error!"< #include #include "Parser.h" +<<<<<<< HEAD //#include "Condition.h" #include "DBEngine.h" +#include "user.h" +======= +#include "Condition.h" +#include "DBEngine.h" +>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61 using namespace std; int main () { - DBEngine engine; +<<<<<<< HEAD + +======= + DBEngine engine; + + Attribute att1("Breakfast", "VARCHAR(20)", true); + Attribute att2("Lunch", "VARCHAR(20)", false); + Attribute att3("Dinner", "VARCHAR(20)", false); + + att1.addCell("Pancakes"); + att1.addCell("Waffles"); + att1.addCell("Biscuits"); + att2.addCell("Turkey Sandwich"); + att2.addCell("Caesar Salad"); + att2.addCell("Pizza"); + att3.addCell("Steak"); + att3.addCell("Shrimp"); + att3.addCell("Ribs"); + + vector v; + v.push_back(att1); + v.push_back(att2); + v.push_back(att3); + + engine.createTable("Food", v); + + //engine.update + + /*actual testing string x; + cout << "Enter DBMS Commands: "; while(getline(cin, x)) { @@ -16,4 +51,6 @@ int main () { parse(x, engine); cout << "Enter DBMS Commands: "; } + */ +>>>>>>> e3ef70bf1536697f14395063975a6376b7df6f61 } diff --git a/user.cpp b/user.cpp new file mode 100755 index 0000000..fce7446 --- /dev/null +++ b/user.cpp @@ -0,0 +1,37 @@ +#include +#include +#include "user.h" + +User::User(){ + name = ""; + password = ""; + phone_number = ""; + fax_number = ""; + postal_address = ""; + is_admin = false; +} + +User::User(string n, string pass, string phone, string fax, string postal, bool admin){ + name = n; + password = pass; + phone_number = phone; + fax_number = fax; + postal_address = postal; + is_admin = admin; +} + +string User::getName() {return name;} +string User::getPassword() {return password;} +string User::getPhoneNumber() {return phone_number;} +string User::getFaxNumber() {return fax_number;} +string User::getPostalAddress() {return postal_address;} +bool User::confirmAdmin() {return is_admin;} +bool User::checkLogin() {return is_logged_in;} +vector User::getGroups(){return groups;} +vector User::getMessages(){return messages;} + +void User::setName(string new_name) {name = new_name;} +void User::setPassword(string new_password) {password = new_password;} +void User::setPhone(string new_phone) {phone_number = new_phone;} +void User::setFax(string new_fax) {fax_number = new_fax;} +void User::setPostal(string new_postal) {postal_address = new_postal;} diff --git a/user.h b/user.h new file mode 100755 index 0000000..c9dcfc8 --- /dev/null +++ b/user.h @@ -0,0 +1,44 @@ +#include +#include +#include + +class User { + string name; + string password; + string phone_number; + string fax_number; + string postal_address; + vector groups; + vector messages; + + bool is_admin; + bool is_logged_in; + +public: + User(); + User(string n, string pass, string phone, string fax, string postal, bool admin); + string getName(); + string getPassword(); + string getPhoneNumber(); + string getFaxNumber(); + string getPostalAddress(); + vector getGroups(); + vector getMessages(); + bool confirmAdmin(); + bool checkLogin(); + void setName(string new_name); + void setPassword(string new_name); + void setPhone(string new_phone); + void setFax(string new_fax); + void setPostal(string new_postal); +}; + +class Message { + string timestamp; + string text; + +public: + Message(); + Message(string time, string t); +}; +