adding cs236
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
#ifndef __TUPLE_H__
|
||||
#define __TUPLE_H__
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class Tuple: public vector<string> {
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef __DB_H__
|
||||
#define __DB_H__
|
||||
|
||||
#include "parser/parser.h"
|
||||
#include "relation.h"
|
||||
|
||||
class db {
|
||||
public:
|
||||
db(parser incoming) {
|
||||
p = incoming;
|
||||
setup();
|
||||
}
|
||||
parser p;
|
||||
vector<relation> relations;
|
||||
|
||||
|
||||
void setup() {
|
||||
for(unsigned int i = 0; i < p.schemelist.size(); i++) {
|
||||
relation r;
|
||||
r.name = p.schemelist[i].id;
|
||||
for(unsigned int j = 0; j < p.schemelist[i].pred_list.size(); j++) {
|
||||
r.schemas.s.push_back(p.schemelist[i].pred_list[j].param);
|
||||
}
|
||||
for(unsigned int k = 0; k < p.factlist.size(); k++) {
|
||||
if(r.name == p.factlist[k].id) {
|
||||
Tuple t;
|
||||
for(unsigned int l = 0; l < p.factlist[k].pred_list.size(); k++) {
|
||||
t.push_back(p.factlist[k].pred_list[l].param);
|
||||
}
|
||||
r.tuples.insert(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//set<string> domain;
|
||||
//vector<predicate> schemelist;
|
||||
//vector<predicate> factlist;
|
||||
//vector<predicate> querylist;
|
||||
//vector<predicate> predlist;
|
||||
//vector<rule> rulelist;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef __RELATION_H__
|
||||
#define __RELATION_H__
|
||||
|
||||
#include "Tuple.h"
|
||||
#include "schema.h"
|
||||
#include <set>
|
||||
|
||||
class relation {
|
||||
public:
|
||||
string name;
|
||||
schema schemas;
|
||||
set<Tuple> tuples;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef __SCHEMA_H__
|
||||
#define __SCHEMA_H__
|
||||
|
||||
#include "Tuple.h"
|
||||
|
||||
class schema {
|
||||
public:
|
||||
Tuple s;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user