Untitled

mail@pastecode.io avatar
unknown
sql
3 years ago
1.5 kB
3
Indexable
CREATE TABLE Users(
    UserID int NOT NULL PRIMARY KEY,
    FirstName varchar(255) NOT NULL,
    LastName varchar(255) NOT NULL,
    Email varchar(255) NOT NULL,
    Score int
);

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,
    OpenQuestionAnswear varchar(8000) NOT NULL,
	FOREIGN KEY (QuestionID) REFERENCES Questions(QuestionID);
)

CREATE TABLE ClosedQuestionAnswears(
	ClosedQuestionAnswearID INT NOT NULL PRIMARY KEY,
	ClosedQuestionAnswear varchar(1024) NOT NULL,
	Correctness BOOLEAN NOT NULL,
    FOREIGN KEY(QuestionID) REFERENCES Questions(QuestionID);
)

CREATE TABLE CorrectOpenQuestionAnswears(
	CorrectOpenQuestionAnswearID int NOT NULL PRIMARY KEY,
	CorrectOpenQuestionAnswear varchar(8000) NOT NULL,
	FOREIGN KEY(QuestionID) REFERENCES Questions(QuestionID)
)

CREATE TABLE UserClosedAnswears(
    UserClosedAnswearID int NOT NULL PRIMARY KEY,
    UserClosedAnswear int,
    FOREIGN KEY (UserID) REFERENCES User(UserID),
    FOREIGN KEY (QuestionID) REFERENCES Questions(QuestionID)
)

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