-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
36 lines (32 loc) · 1007 Bytes
/
schema.sql
File metadata and controls
36 lines (32 loc) · 1007 Bytes
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
CREATE TABLE IF NOT EXISTS segments (
id SERIAL PRIMARY KEY,
active BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS canonical_documents (
id SERIAL PRIMARY KEY,
url TEXT UNIQUE NOT NULL,
title TEXT NOT NULL,
content TEXT NOT NULL,
embedding TEXT
);
CREATE TABLE IF NOT EXISTS segment_documents (
segment_id INTEGER NOT NULL REFERENCES segments(id),
doc_id INTEGER NOT NULL,
canonical_doc_id INTEGER NOT NULL REFERENCES canonical_documents(id),
PRIMARY KEY (segment_id, doc_id)
);
CREATE TABLE IF NOT EXISTS terms (
id SERIAL PRIMARY KEY,
term TEXT UNIQUE NOT NULL,
df INT NOT NULL
);
CREATE TABLE IF NOT EXISTS postings (
segment_id INTEGER NOT NULL REFERENCES segments(id),
term_id INTEGER NOT NULL REFERENCES terms(id),
doc_id INTEGER NOT NULL,
tf INT NOT NULL,
positions INT[] NOT NULL,
offsets INT[] NOT NULL,
PRIMARY KEY (segment_id, term_id, doc_id)
);