#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
