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/DBEngine.h
2015-09-15 23:48:50 -05:00

80 lines
1.7 KiB
C++
Executable file

#include <fstream>
#include <iostream>
#include <vector>
#include "Relation.h"
//still in progress
class DBEngine {
vector<Relation> tables;
int size;
public:
DBEngine(){
size = 0;
}
void createTable(string n, vector<Attribute> a) {
Relation r(n, a);
tables.push_back(r);
}
void createTable(Relation r) { tables.push_back(r); }
vector<Relation> getRelations() { return tables; }
void showTable(Relation r) { r.display(); }
Relation getTableFromName(string n) {
//will return first occurence
for(int i = 0; i < tables.size(); i++) {
if (tables[i].getTableName() == n) {
return tables[i];
}
}
}
void saveToFile(vector<string> cmds) {
ofstream file;
file.open("savefile.db");
for(int i = 0; i < cmds.size(); ++i){
file << cmds[i] << endl;
}
file.close();
}
//void insertTuple(Relation r, vector<string> t) { r.addTuple(t); }
//need to add find by name
/*void deleteTuple(Relation r, int n) {
cout << "a";
r.removeTuple(n); }*/
void selectTuples() {
//
}
void project(Relation r, string n) { r.projectQuery(n); }
/*
Relation product(string p_name, Relation table_1, Relation table_2) {
vector<Attribute> all_att;
//Insert table 1 attributes
all_att.insert(all_att.begin(), (table_1.getAttributes()).begin(), (table_1.getAttributes()).end());
//Insert table 2 attributes
all_att.insert(all_att.begin(), (table_2.getAttributes()).begin(), (table_2.getAttributes()).end());
Relation temp(p_name, all_att);
vector<string> table1_stuff;
return temp;
}
*/
bool unionComp(Relation r1, Relation r2) {
return ((r1.getSize() == r2.getSize()) && (r1.getDomains() == r2.getDomains()));
}
};