new framework
This commit is contained in:
commit
dc3bbcba37
6 changed files with 63 additions and 95 deletions
|
@ -14,7 +14,6 @@ class Attribute {
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
vector<string> values;
|
vector<string> values;
|
||||||
|
|
||||||
Attribute(string n, string t, bool k){
|
Attribute(string n, string t, bool k){
|
||||||
|
@ -44,15 +43,15 @@ public:
|
||||||
{
|
{
|
||||||
cout<<"Atribute name:\t"<<name<<"\n";
|
cout<<"Atribute name:\t"<<name<<"\n";
|
||||||
cout<<"Elements: ";
|
cout<<"Elements: ";
|
||||||
|
|
||||||
for (int i = 0; i < values.size(); ++i)
|
for (int i = 0; i < values.size(); ++i)
|
||||||
{
|
{
|
||||||
cout<<values[i]<<" ";
|
cout<<values[i]<<" ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int getSize()
|
||||||
vector<string> getElements(){
|
{
|
||||||
return values;
|
return values.size();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
57
DBEngine.cpp
57
DBEngine.cpp
|
@ -1,57 +0,0 @@
|
||||||
#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;
|
|
||||||
}
|
|
25
DBEngine.h
25
DBEngine.h
|
@ -3,18 +3,35 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Relation.h"
|
#include "Relation.h"
|
||||||
|
|
||||||
using namespace std;
|
//still in progress
|
||||||
|
|
||||||
class DBEngine {
|
class DBEngine {
|
||||||
vector<Relation> tables;
|
vector<Relation> tables;
|
||||||
|
int size;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DBEngine();
|
DBEngine(){
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void addRelation(Relation r) {
|
void createTable(string n, vector<Attribute> a) {
|
||||||
|
Relation r(n, a);
|
||||||
tables.push_back(r);
|
tables.push_back(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createTable(Relation r) {
|
||||||
|
tables.push_back(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
void showTable() {}
|
||||||
|
void saveToFile() { /*???*/ }
|
||||||
|
void insertTuple() {}
|
||||||
|
void deleteTuple() {}
|
||||||
|
void selectTuples() {}
|
||||||
|
void project() {}
|
||||||
|
void product() {}
|
||||||
|
void unionComp() {}
|
||||||
|
|
||||||
|
|
||||||
vector<Relation> getRelations() {
|
vector<Relation> getRelations() {
|
||||||
return tables;
|
return tables;
|
||||||
}
|
}
|
||||||
|
|
17
Relation.h
17
Relation.h
|
@ -2,9 +2,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Attribute.h"
|
#include "Attribute.h"
|
||||||
|
|
||||||
using namespace std;
|
//Functional
|
||||||
|
|
||||||
//NOT DONE
|
|
||||||
class Relation {
|
class Relation {
|
||||||
string name; //The title the user gives it
|
string name; //The title the user gives it
|
||||||
vector<Attribute> att; //A vector of the columns
|
vector<Attribute> att; //A vector of the columns
|
||||||
|
@ -46,4 +44,17 @@ public:
|
||||||
int getSize() {
|
int getSize() {
|
||||||
return att.size();
|
return att.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void display() {
|
||||||
|
cout<<"\n\nDisplay of relation--------------------------------"<<endl;
|
||||||
|
cout<<"Relation name: "<<name<<endl;
|
||||||
|
for (int i = 0; i < att.size(); ++i)
|
||||||
|
{
|
||||||
|
|
||||||
|
cout<<"\nAttribute name: "<<att[i].getName()<<": ";
|
||||||
|
|
||||||
|
att[i].display();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
BIN
a.out
BIN
a.out
Binary file not shown.
40
test.cpp
40
test.cpp
|
@ -1,30 +1,28 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
//#include "DBEngine.h"
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Attribute.h"
|
#include "DBEngine.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
//still in progress
|
||||||
int main() {
|
int main() {
|
||||||
Attribute atributo("shamWow", "VARCHAR(10)", false);
|
DBEngine engine;
|
||||||
|
|
||||||
atributo.addRow("rag");
|
Attribute att1("shamWow", "VARCHAR(10)", true);
|
||||||
atributo.addRow("sponge");
|
att1.addRow("rag");
|
||||||
atributo.addRow("wooow");
|
att1.addRow("sponge");
|
||||||
atributo.addRow("cloth");
|
att1.addRow("wooow");
|
||||||
|
att1.addRow("cloth");
|
||||||
|
att1.display();
|
||||||
|
|
||||||
atributo.display();
|
Attribute att2("doom", "VARCHAR(20)", false);
|
||||||
|
att2.addRow("zombieman");
|
||||||
|
att2.addRow("revenant");
|
||||||
|
att2.addRow("imp");
|
||||||
|
att2.addRow("archvile");
|
||||||
|
att2.display();
|
||||||
|
|
||||||
Attribute atributo2("doom", "VARCHAR(20)", false);
|
vector<Attribute> vec;
|
||||||
|
vec.push_back(att1);
|
||||||
|
vec.push_back(att2);
|
||||||
|
|
||||||
atributo2.addRow("zombieman");
|
engine.createTable("table1", vec);
|
||||||
atributo2.addRow("revenant");
|
|
||||||
atributo2.addRow("imp");
|
|
||||||
atributo2.addRow("archvile");
|
|
||||||
|
|
||||||
atributo2.display();
|
|
||||||
|
|
||||||
string line1 = "Table_1";
|
|
||||||
|
|
||||||
//Relation r(line1, my_attributes);
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue