Merge pull request #1 from scho4077/master

Update 9/15/15 5:23 PM
This commit is contained in:
Alex Huddleston 2015-09-15 17:23:49 -05:00
commit 8a29955094
6 changed files with 125 additions and 73 deletions

37
Attribute.h Executable file
View file

@ -0,0 +1,37 @@
#include <iostream>
#include <vector>
using namespace std;
//Funtional, might need more functionality
template<typename T>
class Attribute {
//a named column of a relation
string name;
vector<T> values;
bool isKey;
int size;
public:
Attribute(){ }
Attribute(vector<T> v){
this.values = v;
}
Attribute(const Attribute<T>& a){
this.values = a.getAll();
}
Attribute& operator=(const Attribute<T>& a){
this.values = a.getAll();
}
string getName(){
return name;
}
vector<T> getAll(){
return this.values;
}
};

57
DBEngine.cpp Executable file
View file

@ -0,0 +1,57 @@
#include "DBEngine.h"
using namespace std;
DBEngine::DBEngine(){
//
}
//create a new table in memory
void DBEngine::createCmd(){
//
}
//open a txt file, parse SQL script, load data in table
//void DBEngine::openCmd(){
//
//}
//should write cmdList to a .txt file
void DBEngine::saveCmd(){
//
}
//display the database
void DBEngine::showCmd(){
//
}
//add a tuple to a table in the memory
void DBEngine::insertQuery(){
//
}
//remove a tuple from a table in the memory
void DBEngine::deleteQuery(){
//
}
//search and return one more tuples from a table in the memory
void DBEngine::selectQuery(){
//
}
//return a subset of attributes (columns)
void DBEngine::projectQuery(){
//
}
//each row in the first table is paired with all the rows in the second table
void DBEngine::productQuery(){
//
}
//true if relations have the same # of attributes and each attribute must be from the same domain
bool DBEngine::unionComp(){
return false;
}

View file

@ -1,12 +1,17 @@
#include <fstream>
#include <iostream>
#include <vector>
#include "Relation.h"
class db_engine {
std::vector<std::string> cmdList;
using namespace std;
class DBEngine {
//member variables
//NOT DONE
//vector<Relation> tables;
public:
db_engine();
DBEngine();
void createCmd();
//void openCmd();
void saveCmd();

16
Relation.h Executable file
View file

@ -0,0 +1,16 @@
#include <iostream>
#include <vector>
#include "Attribute.h"
using namespace std;
//NOT DONE
class Relation {
//a table with rows and columns
string name;
vector< Attribute<T> > att;
public:
Relation();
Relation(vector< Attribute<T> > a) { att = a; }
void addTuple(vector< Attribute<T> > tuple);
};

View file

@ -1,65 +0,0 @@
#include "db_engine.h"
db_engine::db_engine(){
//
}
//create a new table in memory
//creates a vector
void db_engine::createCmd(){
//
}
//open a txt file, parse SQL script, load data in table
//void db_engine::openCmd(){
//
//}
//should write cmdList to a .txt file
void db_engine::saveCmd(){
std::ofstream dbCmdFile;
dbCmdFile.open("dbCmds.txt", std::ios_base::app);
std::vector<std::string>::iterator it = cmdList.begin();
while (it != cmdList.end()){
dbCmdFile << *it << "\n";
++it;
}
cmdList.clear();
}
//display the table currently stored in memory
void db_engine::showCmd(){
//
}
//add a tuple to a table in the memory
void db_engine::insertQuery(){
//
}
//remove a tuple from a table in the memory
void db_engine::deleteQuery(){
//
}
//search and return one more tuples from a table in the memory
void db_engine::selectQuery(){
//
}
//return a subset of attributes (columns)
void db_engine::projectQuery(){
//
}
//each row in the first table is paired with all the rows in the second table
void db_engine::productQuery(){
//
}
//true if relations have the same # of attributes and each attribute must be from the same domain
bool db_engine::unionComp(){
return false;
}

View file

@ -1,8 +1,10 @@
#include <iostream>
#include "db_engine.h"
#include "DBEngine.h"
using namespace std;
int main() {
db_engine engine;
engine.saveCmd();
std::cout << "succesfully traversed the code!";
}
DBEngine engine;
Relation r;
Attribute<int> a;
}