Align and comment code
This commit is contained in:
parent
1dbf4b868f
commit
672bdd2f9a
3 changed files with 36 additions and 23 deletions
|
@ -1,13 +1,16 @@
|
|||
BEGIN;
|
||||
|
||||
CREATE TABLE languages (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
code VARCHAR(2) NOT NULL,
|
||||
english_name VARCHAR NOT NULL,
|
||||
self_name VARCHAR NOT NULL,
|
||||
CONSTRAINT code_is_language_code CHECK (is_language_code(code)),
|
||||
-- name type constraints
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
code VARCHAR(2) NOT NULL,
|
||||
english_name VARCHAR NOT NULL,
|
||||
self_name VARCHAR NOT NULL,
|
||||
|
||||
-- CONSTRAINT name CHECK (condition)
|
||||
CONSTRAINT code_is_language_code CHECK (is_language_code(code)),
|
||||
CONSTRAINT english_name_is_sane_text CHECK (is_sane_text(english_name)),
|
||||
CONSTRAINT self_name_is_sane_text CHECK (is_sane_text(self_name))
|
||||
CONSTRAINT self_name_is_sane_text CHECK (is_sane_text(self_name))
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX languages_code ON languages (code);
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
BEGIN;
|
||||
|
||||
CREATE TABLE examples (
|
||||
id BIGSERIAL PRIMARY KEY
|
||||
-- name type constraints
|
||||
id BIGSERIAL PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE example_texts (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
example_id BIGINT NOT NULL REFERENCES examples (id),
|
||||
language_id BIGINT NOT NULL REFERENCES languages (id),
|
||||
index BIGINT NOT NULL,
|
||||
value TEXT NOT NULL,
|
||||
CONSTRAINT index_is_not_negative CHECK(index >= 0),
|
||||
CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
|
||||
-- name type constraints
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
example_id BIGINT NOT NULL REFERENCES examples (id),
|
||||
language_id BIGINT NOT NULL REFERENCES languages (id),
|
||||
index BIGINT NOT NULL,
|
||||
value TEXT NOT NULL,
|
||||
|
||||
-- CONSTRAINT name CHECK (condition)
|
||||
CONSTRAINT index_is_not_negative CHECK (index >= 0),
|
||||
CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX example_texts_example_language_index
|
||||
|
|
|
@ -1,23 +1,29 @@
|
|||
BEGIN;
|
||||
|
||||
CREATE TABLE words (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
language_id BIGINT NOT NULL REFERENCES languages (id),
|
||||
primary_form VARCHAR NOT NULL,
|
||||
-- name type constraints
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
language_id BIGINT NOT NULL REFERENCES languages (id),
|
||||
primary_form VARCHAR NOT NULL,
|
||||
|
||||
-- CONSTRAINT name CHECK (condition)
|
||||
CONSTRAINT primary_form_is_sane_text CHECK (is_sane_text(primary_form))
|
||||
);
|
||||
|
||||
CREATE TABLE word_forms (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
word_id BIGINT NOT NULL REFERENCES words (id),
|
||||
value VARCHAR NOT NULL,
|
||||
-- name type constraints
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
word_id BIGINT NOT NULL REFERENCES words (id),
|
||||
value VARCHAR NOT NULL,
|
||||
|
||||
-- CONSTRAINT name CHECK (condition)
|
||||
CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
|
||||
);
|
||||
|
||||
CREATE TABLE word_form_example_texts (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
word_form_id BIGINT NOT NULL REFERENCES word_forms (id),
|
||||
example_text_id BIGINT NOT NULL REFERENCES example_texts (id)
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
word_form_id BIGINT NOT NULL REFERENCES word_forms (id),
|
||||
example_text_id BIGINT NOT NULL REFERENCES example_texts (id)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX word_forms_word_value_index ON word_forms (word_id, value);
|
||||
|
|
Loading…
Reference in a new issue