-- CREATE TABLE

CREATE TABLE geo_values (
    id integer NOT NULL,
    strdfgeo geometry
);

CREATE TABLE label_values (
    id integer NOT NULL,
    value character varying(255) NOT NULL
);

CREATE TABLE long_label_values (
    id integer NOT NULL,
    value text NOT NULL
);

CREATE TABLE long_uri_values (
    id integer NOT NULL,
    value text NOT NULL
);

CREATE TABLE triples (
    ctx integer NOT NULL,
    subj integer NOT NULL,
    pred integer NOT NULL,
    obj integer NOT NULL,
    expl boolean NOT NULL,
    interval_start timestamp,
    interval_end timestamp
);

CREATE TABLE uri_values (
    id integer NOT NULL,
    value character varying(255) NOT NULL
);

-- ADD PRIMARY KEY

ALTER TABLE  geo_values
    ADD CONSTRAINT geo_values_pkey PRIMARY KEY (id);

ALTER TABLE  label_values
    ADD CONSTRAINT label_values_pkey PRIMARY KEY (id);

ALTER TABLE  long_label_values
    ADD CONSTRAINT long_label_values_pkey PRIMARY KEY (id);

ALTER TABLE  long_uri_values
    ADD CONSTRAINT long_uri_values_pkey PRIMARY KEY (id);

ALTER TABLE  triples
    ADD CONSTRAINT triples_pkey PRIMARY KEY (obj, subj, pred, ctx, expl);

ALTER TABLE  uri_values
    ADD CONSTRAINT uri_values_pkey PRIMARY KEY (id);

-- CREATE INDEX

CREATE INDEX geoindex ON geo_values (strdfgeo);

CREATE INDEX triples_ctx_idx ON triples (ctx);

CREATE INDEX triples_expl_idx ON triples (expl);

CREATE INDEX triples_pred_idx ON triples (pred);

CREATE INDEX triples_subj_idx ON triples (subj);

