Untitled

mail@pastecode.io avatar
unknown
sql
2 years ago
1.8 kB
2
Indexable
Never
CREATE TABLE Users
(
    UserID        INT          NOT NULL PRIMARY KEY,
    UserFirstName varchar(255) NOT NULL,
    UserLastName  varchar(255) NOT NULL,
    UserEmail     varchar(255) NOT NULL,
);

CREATE TABLE Questions
(
    QuestionID   INT           NOT NULL PRIMARY KEY,
    QuestionType varchar(255)  NOT NULL,
    Question     varchar(4096) NOT NULL
);

CREATE TABLE OpenQuestionsHints
(
    OpenQuestionHintID INT           NOT NULL PRIMARY KEY,
    Hint               varchar(8000) NOT NULL,
    FOREIGN KEY (QuestionID) REFERENCES Questions (QuestionID)
);

CREATE TABLE ClosedQuestionAnswears
(
    ClosedQuestionAnswearID INT           NOT NULL PRIMARY KEY,
    Answear                 varchar(1024) NOT NULL,
    FOREIGN KEY (QuestionID) REFERENCES Questions (QuestionID)
)

CREATE TABLE CorrectOpenAnswears
(
    CorrectOpenAnswearID INT           NOT NULL PRIMARY KEY,
    Answear              varchar(8000) NOT NULL,
    FOREIGN KEY (QuestionID) REFERENCES Questions (QuestionID),
)

CREATE TABLE CorrectClosedAnswears
(
    FOREIGN KEY (ClosedQuestionAnswearID) REFERENCES ClosedQuestionAnswears (ClosedQuestionAnswearID),
    FOREIGN KEY (QuestionID) REFERENCES Questions (QuestionID)
)


CREATE TABLE UserClosedAnswears
(
    UserClosedAnswearID INT NOT NULL PRIMARY KEY,
    FOREIGN KEY (UserID) REFERENCES User (UserID),
    FOREIGN KEY (ClosedQuestionAnswearID) REFERENCES ClosedQuestionAnswears (ClosedQuestionAnswearID),
    FOREIGN KEY (QuestionID) REFERENCES Questions (QuestionID)
)

CREATE TABLE UserOpenAnswears
(
    UserOpenAnswearID INT NOT NULL PRIMARY KEY,
    Answear           varchar(8000),
    FOREIGN KEY (UserID) REFERENCES User (UserID),
    FOREIGN KEY (QuestionID) REFERENCES Questions (QuestionID)
)