DROP TABLE IF EXISTS main;
DROP TABLE IF EXISTS first_name;
DROP TABLE IF EXISTS last_name;
DROP TABLE IF EXISTS middle_name;
DROP TABLE IF EXISTS discipline;
CREATE TABLE first_name (
    first_name_id SERIAL PRIMARY KEY,
    first_name_val VARCHAR(255) NOT NULL
);
CREATE TABLE last_name (
    last_name_id SERIAL PRIMARY KEY,
    last_name_val VARCHAR(255) NOT NULL
);
CREATE TABLE middle_name (
    middle_name_id SERIAL PRIMARY KEY,
    middle_name_val VARCHAR(255) NOT NULL
);
CREATE TABLE discipline (
    discipline_id SERIAL PRIMARY KEY,
    discipline_val VARCHAR(255) NOT NULL
);
CREATE TABLE main (
    uid serial,
    last_name int,
    first_name int,
    middle_name int,
    discipline int,
    mark VARCHAR(255),
    CONSTRAINT fk_last_name FOREIGN KEY (last_name) REFERENCES last_name(last_name_id),
    CONSTRAINT fk_first_name FOREIGN KEY (first_name) REFERENCES first_name(first_name_id),
    CONSTRAINT fk_middle_name FOREIGN KEY (middle_name) REFERENCES middle_name(middle_name_id),
    CONSTRAINT fk_discipline FOREIGN KEY (discipline) REFERENCES discipline(discipline_id),
    PRIMARY KEY (uid)
);
