Doing things.
This commit is contained in:
parent
b5093be722
commit
7c8eb084d9
6 changed files with 20 additions and 16 deletions
|
@ -7,6 +7,7 @@ Attribute::Attribute(){
|
||||||
type = "";
|
type = "";
|
||||||
key = 0;
|
key = 0;
|
||||||
size = 0;
|
size = 0;
|
||||||
|
limit = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Attribute::Attribute(string n, string t, bool k){
|
Attribute::Attribute(string n, string t, bool k){
|
||||||
|
@ -14,13 +15,15 @@ Attribute::Attribute(string n, string t, bool k){
|
||||||
type = t;
|
type = t;
|
||||||
key = k;
|
key = k;
|
||||||
size = 0;
|
size = 0;
|
||||||
|
limit = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
Attribute::Attribute(string n, string t, bool k, int s){
|
Attribute::Attribute(string n, string t, bool k, int s){
|
||||||
name = n;
|
name = n;
|
||||||
type = t;
|
type = t;
|
||||||
key = k;
|
key = k;
|
||||||
size = s;
|
size = 0;
|
||||||
|
limit = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attribute::addCell(string v){
|
void Attribute::addCell(string v){
|
||||||
|
|
|
@ -10,6 +10,7 @@ class Attribute{
|
||||||
string type;
|
string type;
|
||||||
bool key;
|
bool key;
|
||||||
int size;
|
int size;
|
||||||
|
int limit;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Attribute();
|
Attribute();
|
||||||
|
|
|
@ -25,7 +25,7 @@ void DBEngine::createTable(Relation r){
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBEngine::insertValues(string r, vector <string> v)
|
void DBEngine::insertValues(string r, vector<string> v)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < tables.size(); i++)
|
for(int i = 0; i < tables.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -58,11 +58,12 @@ void DBEngine::save(string n){
|
||||||
string name = n + ".txt";
|
string name = n + ".txt";
|
||||||
file.open(name);
|
file.open(name);
|
||||||
|
|
||||||
for(int i = 0; i < commands.size(); ++i){
|
for(int i = 0; i < commands.size(); ++i)
|
||||||
|
{
|
||||||
file << commands[i] << endl;
|
file << commands[i] << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
//file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Relation> DBEngine::getRelations(){
|
vector<Relation> DBEngine::getRelations(){
|
||||||
|
|
15
DBEngine.h
15
DBEngine.h
|
@ -21,22 +21,13 @@ public:
|
||||||
Relation& getTableFromName(string n);
|
Relation& getTableFromName(string n);
|
||||||
void saveToFile(vector<string> cmds);
|
void saveToFile(vector<string> cmds);
|
||||||
Relation selection(string attName, string s, Relation r);
|
Relation selection(string attName, string s, Relation r);
|
||||||
Relation projection(vector<string> input, Relation r);
|
Relation projection(vector<string> input, Relation r);
|
||||||
<<<<<<< HEAD
|
Relation product(string s1, Relation r1, Relation r2);
|
||||||
Relation product(string s1, Relation r1, Relation r2);
|
|
||||||
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
|
||||||
void save();
|
void save();
|
||||||
void save(string n);
|
void save(string n);
|
||||||
void storeCommands(string s);
|
|
||||||
Relation setUnion(Relation r1, Relation r2);
|
|
||||||
//void setDiff();
|
|
||||||
//void crossProduct();
|
|
||||||
=======
|
|
||||||
void save();
|
|
||||||
void storeCommands(string s);
|
void storeCommands(string s);
|
||||||
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
||||||
Relation setUnion(Relation r1, Relation r2);
|
Relation setUnion(Relation r1, Relation r2);
|
||||||
Relation setDiff(Relation r1, Relation r2);
|
Relation setDiff(Relation r1, Relation r2);
|
||||||
Relation crossProduct(Relation r1, Relation r2);
|
Relation crossProduct(Relation r1, Relation r2);
|
||||||
>>>>>>> master
|
|
||||||
};
|
};
|
||||||
|
|
BIN
test
BIN
test
Binary file not shown.
8
test.cpp
8
test.cpp
|
@ -48,4 +48,12 @@ int main () {
|
||||||
//engine.getTableFromName("MoarFood").display();
|
//engine.getTableFromName("MoarFood").display();
|
||||||
|
|
||||||
engine.crossProduct(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display();
|
engine.crossProduct(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: ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue