2023-02-11 00:09:19 -05:00
|
|
|
BEGIN;
|
|
|
|
|
|
|
|
CREATE TABLE words (
|
2023-02-18 01:41:59 -05:00
|
|
|
-- name type constraints
|
|
|
|
id BIGSERIAL PRIMARY KEY,
|
|
|
|
language_id BIGINT NOT NULL REFERENCES languages (id),
|
|
|
|
primary_form VARCHAR NOT NULL,
|
|
|
|
|
|
|
|
-- CONSTRAINT name CHECK (condition)
|
2023-02-11 00:09:19 -05:00
|
|
|
CONSTRAINT primary_form_is_sane_text CHECK (is_sane_text(primary_form))
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE word_forms (
|
2023-02-18 01:41:59 -05:00
|
|
|
-- name type constraints
|
|
|
|
id BIGSERIAL PRIMARY KEY,
|
|
|
|
word_id BIGINT NOT NULL REFERENCES words (id),
|
|
|
|
value VARCHAR NOT NULL,
|
|
|
|
|
|
|
|
-- CONSTRAINT name CHECK (condition)
|
2023-02-11 00:09:19 -05:00
|
|
|
CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE word_form_example_texts (
|
2023-02-18 01:41:59 -05:00
|
|
|
id BIGSERIAL PRIMARY KEY,
|
|
|
|
word_form_id BIGINT NOT NULL REFERENCES word_forms (id),
|
|
|
|
example_text_id BIGINT NOT NULL REFERENCES example_texts (id)
|
2023-02-11 00:09:19 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE UNIQUE INDEX word_forms_word_value_index ON word_forms (word_id, value);
|
|
|
|
|
|
|
|
COMMIT;
|