-
Notifications
You must be signed in to change notification settings - Fork 4
PostgresSQL Table Schema
Utkarsh Patel edited this page Nov 22, 2017
·
9 revisions
CREATE TABLE IF NOT EXISTS document (
_id SERIAL NOT NULL,
text_id TEXT UNIQUE NOT NULL,
length DOUBLE PRECISION NOT NULL,
parent_doc INTEGER,
"type" SMALLINT NOT NULL DEFAULT 1,
PRIMARY KEY (_id)
);
CREATE TABLE IF NOT EXISTS term (
_id SERIAL NOT NULL,
term TEXT UNIQUE NOT NULL,
PRIMARY KEY (_id)
);
CREATE TABLE IF NOT EXISTS gram (
gram_id SERIAL NOT NULL,
term_id_1 INT NOT NULL,
term_id_2 INT,
PRIMARY KEY (gram_id, term_id_1, term_id_2),
FOREIGN KEY (term_id_1) REFERENCES term(_id),
FOREIGN KEY (term_id_2) REFERENCES term(_id)
);
CREATE TABLE IF NOT EXISTS tf (
gram_id INTEGER NOT NULL,
doc_id INTEGER NOT NULL,
lnc DOUBLE PRECISION NOT NULL,
PRIMARY KEY (gram_id, doc_id),
FOREIGN KEY (doc_id) REFERENCES document(_id)
);
CREATE TABLE IF NOT EXISTS idf (
gram_id INT UNIQUE NOT NULL,
df BIGINT NOT NULL
);