1
0
Fork 0

Align and comment code

This commit is contained in:
Alex Kotov 2023-02-18 10:41:59 +04:00
parent 1dbf4b868f
commit 672bdd2f9a
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 36 additions and 23 deletions

View file

@ -1,13 +1,16 @@
BEGIN; BEGIN;
CREATE TABLE languages ( CREATE TABLE languages (
id BIGSERIAL PRIMARY KEY, -- name type constraints
code VARCHAR(2) NOT NULL, id BIGSERIAL PRIMARY KEY,
english_name VARCHAR NOT NULL, code VARCHAR(2) NOT NULL,
self_name VARCHAR NOT NULL, english_name VARCHAR NOT NULL,
CONSTRAINT code_is_language_code CHECK (is_language_code(code)), 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 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); CREATE UNIQUE INDEX languages_code ON languages (code);

View file

@ -1,17 +1,21 @@
BEGIN; BEGIN;
CREATE TABLE examples ( CREATE TABLE examples (
id BIGSERIAL PRIMARY KEY -- name type constraints
id BIGSERIAL PRIMARY KEY
); );
CREATE TABLE example_texts ( CREATE TABLE example_texts (
id BIGSERIAL PRIMARY KEY, -- name type constraints
example_id BIGINT NOT NULL REFERENCES examples (id), id BIGSERIAL PRIMARY KEY,
language_id BIGINT NOT NULL REFERENCES languages (id), example_id BIGINT NOT NULL REFERENCES examples (id),
index BIGINT NOT NULL, language_id BIGINT NOT NULL REFERENCES languages (id),
value TEXT NOT NULL, index BIGINT NOT NULL,
CONSTRAINT index_is_not_negative CHECK(index >= 0), value TEXT NOT NULL,
CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
-- 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 CREATE UNIQUE INDEX example_texts_example_language_index

View file

@ -1,23 +1,29 @@
BEGIN; BEGIN;
CREATE TABLE words ( CREATE TABLE words (
id BIGSERIAL PRIMARY KEY, -- name type constraints
language_id BIGINT NOT NULL REFERENCES languages (id), id BIGSERIAL PRIMARY KEY,
primary_form VARCHAR NOT NULL, 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)) CONSTRAINT primary_form_is_sane_text CHECK (is_sane_text(primary_form))
); );
CREATE TABLE word_forms ( CREATE TABLE word_forms (
id BIGSERIAL PRIMARY KEY, -- name type constraints
word_id BIGINT NOT NULL REFERENCES words (id), id BIGSERIAL PRIMARY KEY,
value VARCHAR NOT NULL, 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)) CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
); );
CREATE TABLE word_form_example_texts ( CREATE TABLE word_form_example_texts (
id BIGSERIAL PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
word_form_id BIGINT NOT NULL REFERENCES word_forms (id), word_form_id BIGINT NOT NULL REFERENCES word_forms (id),
example_text_id BIGINT NOT NULL REFERENCES example_texts (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); CREATE UNIQUE INDEX word_forms_word_value_index ON word_forms (word_id, value);