BEGIN;

CREATE TABLE part_names (
--  name         type      constraints
    id           BIGSERIAL PRIMARY KEY,
    part_id      BIGINT    NOT NULL REFERENCES parts (id),
    name_lang_id BIGINT    NOT NULL REFERENCES languages (id),
    value        VARCHAR   NOT NULL,

--  CONSTRAINT name               CHECK (condition)
    CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
);

CREATE UNIQUE INDEX part_names_part_name_lang
    ON part_names (part_id, name_lang_id);
CREATE UNIQUE INDEX part_names_name_lang_value
    ON part_names (name_lang_id, value);

COMMIT;
