-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchDB.sql
48 lines (43 loc) · 1.04 KB
/
searchDB.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
CREATE TABLE public.document
(
id serial,
url character varying(255),
"timestamp" timestamp without time zone,
CONSTRAINT docid_idx PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.document
OWNER TO search;
CREATE TABLE public.term
(
id serial,
value character varying(255),
CONSTRAINT termid_idx PRIMARY KEY (id),
CONSTRAINT value_uniq UNIQUE (value)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.term
OWNER TO search;
CREATE TABLE public.term_doc
(
docid integer NOT NULL,
termid integer NOT NULL,
"position" integer NOT NULL,
CONSTRAINT term_doc_id_idx PRIMARY KEY (docid, termid, "position"),
CONSTRAINT fk_docid FOREIGN KEY (docid)
REFERENCES public.document (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_termid FOREIGN KEY (termid)
REFERENCES public.term (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.term_doc
OWNER TO search;
--INSERT INTO document (url,timestamp) VALUES ('test.pdf', NOW()::timestamp)