BEGIN;

CREATE TABLE parts (
--  name         type      constraints
    id           BIGSERIAL PRIMARY KEY,
    language_id  BIGINT    NOT NULL REFERENCES languages (id),
    english_name VARCHAR   NOT NULL,

--  CONSTRAINT name                      CHECK (condition)
    CONSTRAINT english_name_is_sane_text CHECK (is_sane_text(english_name))
);

CREATE UNIQUE INDEX parts_language_english_name
    ON parts (language_id, english_name);

ALTER TABLE words ADD COLUMN part_id BIGINT REFERENCES parts (id);

COMMIT;
