This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
dmspine64backup/test.cpp

152 lines
3.5 KiB
C++
Raw Normal View History

2015-09-15 20:16:58 -05:00
#include <iostream>
#include <vector>
#include "Parserv3.h"
//#include "Condition.h"
2015-09-15 21:31:19 -05:00
#include "DBEngine.h"
2015-09-15 20:16:58 -05:00
using namespace std;
2015-09-14 15:04:54 -05:00
2015-09-15 21:31:19 -05:00
//still in progress
2015-09-25 00:29:00 -05:00
/*
2015-09-14 15:04:54 -05:00
int main() {
2015-09-15 20:16:58 -05:00
DBEngine engine;
2015-09-17 17:14:28 -05:00
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<Attribute> v;
v.push_back(att1);
v.push_back(att2);
v.push_back(att3);
2015-09-25 00:29:00 -05:00
Relation r("Food", v);
2015-09-22 09:03:42 -05:00
//r.renameAttribute("Breakfast", "BFST");
//r.display();
engine.createTable("Food", v);
2015-09-17 17:14:28 -05:00
2015-09-21 16:27:23 -05:00
vector<string> tuple;
tuple.push_back("Omelette");
tuple.push_back("Fried Rice");
tuple.push_back("Grouper");
2015-09-17 18:30:45 -05:00
2015-09-22 09:03:42 -05:00
engine.getTableFromName("Food").insertTuple(tuple);
2015-09-17 18:30:45 -05:00
2015-09-22 09:03:42 -05:00
vector<string> old;
vector<string> newa;
2015-09-21 16:27:23 -05:00
2015-09-22 09:03:42 -05:00
old.push_back("Breakfast");
old.push_back("Lunch");
old.push_back("Dinner");
2015-09-21 16:27:23 -05:00
2015-09-22 09:03:42 -05:00
newa.push_back("Tsafkaerb");
newa.push_back("Hcnul");
newa.push_back("Rennid");
2015-09-21 16:27:23 -05:00
2015-09-22 00:05:17 -05:00
//Projection test
vector<string> projectTest;
projectTest.push_back("Breakfast");
projectTest.push_back("Dinner");
cout << "\n***Initiated Projection***\n" << endl;
Relation sub_r = engine.projection(projectTest, r);
sub_r.display();
2015-09-21 16:27:23 -05:00
//engine.rename(r, o, n);
2015-09-25 00:29:00 -05:00
2015-09-22 09:03:42 -05:00
engine.rename(engine.getTableFromName("Food"), old, newa);
engine.getTableFromName("Food").display();
cout << "finished";
2015-09-25 00:29:00 -05:00
}
*/
int main () {
/*
2015-09-25 00:29:00 -05:00
string ss = "INSERT INTO animals VALUES FROM ( Joe , cat , 4 ) ;";
string ss2 = "SHOW Dogs ;";
string ss3 = "EXIT ; ";
*/
2015-09-25 00:29:00 -05:00
DBEngine engine;
// vector<string> listOfTokens = tokenize(ss);
// vector<string> listOfTokens2 = tokenize(ss2);
// vector<string> listOfTokens3 = tokenize(ss3);
// par_line(listOfTokens);
// par_line(listOfTokens2);
// par_line(listOfTokens3);
// parse(ss, engine);
// parse(ss2, engine);
// parse(ss3, engine);
2015-09-25 00:29:00 -05:00
// engine.save();
2015-09-27 15:27:14 -05:00
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<Attribute> v;
v.push_back(att1);
v.push_back(att2);
v.push_back(att3);
engine.createTable("Food", v);
2015-09-26 23:24:24 -05:00
Attribute att4("Breakfast", "VARCHAR(20)", true);
Attribute att5("Lunch", "VARCHAR(20)", false);
Attribute att6("Dinner", "VARCHAR(20)", false);
att4.addCell("Pancakes");
att4.addCell("Bacon");
att4.addCell("Eggs");
att5.addCell("Turkey Sandwich");
att5.addCell("Pasta Salad");
att5.addCell("Taco");
att6.addCell("Steak");
att6.addCell("Fajitas");
att6.addCell("Spaghetti");
vector<Attribute> v2;
v2.push_back(att4);
v2.push_back(att5);
v2.push_back(att6);
engine.createTable("MoarFood", v2);
2015-09-27 15:27:14 -05:00
engine.getTableFromName("Food").display();
engine.getTableFromName("MoarFood").display();
2015-09-26 23:24:24 -05:00
//engine.setUnion(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display();
string x;
cout << "Enter DBMS Commands: ";
while(getline(cin, x))
{
//cout << x << endl;
parse(x, engine);
cout << "Enter DBMS Commands: ";
}
2015-09-25 00:29:00 -05:00
}