Skip to content

Instantly share code, notes, and snippets.

@vanhouc
Last active August 29, 2015 13:55
Show Gist options
  • Save vanhouc/8701660 to your computer and use it in GitHub Desktop.
Save vanhouc/8701660 to your computer and use it in GitHub Desktop.
/*QuizBuilder create_database query
By: Cameron VanHouzen
Date: 1/29/14
The MIT License (MIT)
Copyright (c) <2014> <Cameron VanHouzen>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
create table Users
(
UserID int not null primary key,
FirstName varchar not null,
LastName varchar not null,
Username varchar not null,
Password varchar not null,
Email varchar not null,
IsAdmin bit not null
);
create table QuestionOptions
(
QuestionOptionID int not null primary key,
QuestionID int not null,
OptionSequence varchar not null,
OptionText varchar not null,
IsRichText bit not null,
IsCorrect bit not null
foreign key (QuestionID) references Questions (QuestionID)
);
create table Questions
(
QuestionID int not null primary key,
ScenarioID int not null,
QuestionTypeID int not null,
QuestionContent varchar not null,
AnswerContent varchar not null,
foreign key (ScenarioID) references Scenarios (ScenarioID)
);
create table Quizzes
(
QuizID int not null primary key,
QuizAuthor varchar not null,
QuizName varchar not null,
QuestionPoolID int not null,
);
create table QuestionResponses
(
QuestionResponseID int not null primary key
QuizAttemptID int not null,
QuestionID int not null,
IsCorrect bit not null,
UserReviewFlag bit not null,
foreign key (QuestionID) references Questions (QuestionID),
foreign key (QuestionOptionID) references QuestionOptions (QuestionOptionID),
foreign key (QuizAttemptID) references QuizAttempts (QuizAttemptID)
);
create table Scenarios
(
ScenarioID int not null primary key,
QuizID int not null,
ScenarioSequence int not null,
ScenarioName varchar not null,
ScenarioText varchar not null,
IsRichText bit not null,
foreign key (QuizID) references Quizzes (QuizID)
);
create table QuizAttempts
(
QuizAttemptID int not null primary key,
UserID int not null,
QuizID int not null,
Score float not null,
QuizDate date not null,
foreign key (UserID) references Users(UserID),
foreign key (QuizID) references Quizzes (QuizID)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment