diff --git a/sql/schema.sql b/sql/schema.sql index 61a97de..8d79aff 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -37,6 +37,12 @@ CONSTRAINT FK_Criterion_Criterion_Type FOREIGN KEY (Criterion_Type) REFERENCES Criterion_type (Criterion_Type) ); +CREATE TABLE Team ( + Team_ID VARCHAR NOT NULL, + Name VARCHAR NOT NULL, + CONSTRAINT PK_Team PRIMARY KEY (Team_ID) +); + CREATE TABLE Student ( Submission_ID VARCHAR UNIQUE NOT NULL, Student_ID VARCHAR UNIQUE NOT NULL, @@ -46,22 +52,16 @@ Email VARCHAR UNIQUE NOT NULL, Send_Feedback BOOLEAN NOT NULL DEFAULT TRUE, Email_Sent BOOLEAN NOT NULL DEFAULT FALSE, - Team_ID VARCHAR, - CONSTRAINT PK_Student PRIMARY KEY (Submission_ID) + Team_ID VARCHAR UNIQUE, + CONSTRAINT PK_Student PRIMARY KEY (Submission_ID), CONSTRAINT FK_Student_Team FOREIGN KEY (Team_ID) REFERENCES Team (Team_ID) ); CREATE TABLE Submission ( Submission_ID VARCHAR PRIMARY KEY, Name VARCHAR NOT NULL, - CONSTRAINT FK_Submission_Student FOREIGN KEY (Submission_ID) REFERENCES Student (Submission_ID) --- CONSTRAINT FK_Submission_Team FOREIGN KEY (Submission_ID) REFERENCES Student (Team_ID) -); - -CREATE TABLE Team ( - Team_ID VARCHAR NOT NULL, - Name VARCHAR NOT NULL, - CONSTRAINT PK_Team PRIMARY KEY (Team_ID) + CONSTRAINT FK_Submission_Student FOREIGN KEY (Submission_ID) REFERENCES Student (Submission_ID), + CONSTRAINT FK_Submission_Team FOREIGN KEY (Submission_ID) REFERENCES Student (Team_ID) ); CREATE TABLE Result (