CREATE TABLE PROFESSOR (
    PROFESSOR_ID BIGINT GENERATED ALWAYS AS IDENTITY NOT NULL, NAME VARCHAR(255),
    PRIMARY KEY (PROFESSOR_ID)
);


CREATE TABLE STUDENTGROUP (
    STUDENT_GROUP_ID BIGINT GENERATED ALWAYS AS IDENTITY NOT NULL,
    GROUPNAME VARCHAR(255), 
    PRIMARY KEY (STUDENT_GROUP_ID)
);


CREATE TABLE STUDENT (
    STUDENT_ID BIGINT GENERATED ALWAYS AS IDENTITY NOT NULL,
    NAME VARCHAR(255),
    STUDENTGROUP_STUDENT_GROUP_ID BIGINT,
    FOREIGN KEY (STUDENTGROUP_STUDENT_GROUP_ID) REFERENCES STUDENTGROUP
);

CREATE TABLE COURSE (
    COURSE_ID BIGINT GENERATED ALWAYS AS IDENTITY NOT NULL,
    TITLE VARCHAR(255), 
    PROFESSOR_PROFESSOR_ID BIGINT,
    STUDENTGROUP_STUDENT_GROUP_ID BIGINT,
    PRIMARY KEY (COURSE_ID),
    FOREIGN KEY (PROFESSOR_PROFESSOR_ID) REFERENCES PROFESSOR,
    FOREIGN KEY (STUDENTGROUP_STUDENT_GROUP_ID) REFERENCES STUDENTGROUP
);

CREATE TABLE COURSEDOMAIN (
    COURSEDOMAIN_ID BIGINT GENERATED ALWAYS AS IDENTITY NOT NULL,
    LABEL VARCHAR(255), 
    PRIMARY KEY (COURSEDOMAIN_ID)
);

CREATE TABLE COURSE_COURSEDOMAIN (
    COURSE_ID BIGINT NOT NULL,
    COURSEDOMAIN_ID BIGINT NOT NULL,
    PRIMARY KEY (COURSE_ID, COURSEDOMAIN_ID),
    FOREIGN KEY (COURSE_ID) REFERENCES COURSE,
    FOREIGN KEY (COURSEDOMAIN_ID) REFERENCES COURSEDOMAIN
);


