bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
1 |
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; |
2 |
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; |
|
3 |
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; |
|
4 |
||
5 |
CREATE SCHEMA IF NOT EXISTS `lenasys` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; |
|
6 |
USE `lenasys` ; |
|
7 |
||
8 |
-- ----------------------------------------------------- |
|
|
29.1.3
by b11johgu
changed the order on the tables. |
9 |
-- Table `lenasys`.`Users` |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
10 |
-- ----------------------------------------------------- |
|
29.1.3
by b11johgu
changed the order on the tables. |
11 |
CREATE TABLE IF NOT EXISTS `lenasys`.`Users` ( |
12 |
`userName` VARCHAR(20) NOT NULL , |
|
13 |
`name` VARCHAR(45) NULL , |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
14 |
`passwd` VARCHAR(45) NULL , |
15 |
`userType` INT NULL , -- teacher or student |
|
16 |
`ssn` CHAR(13) NULL COMMENT 'yyyymmdd-xxxx' , |
|
|
29.1.3
by b11johgu
changed the order on the tables. |
17 |
PRIMARY KEY (`userName`) , |
18 |
UNIQUE INDEX `userName_UNIQUE` (`userName` ASC) ) |
|
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
19 |
ENGINE = InnoDB; |
20 |
||
21 |
-- ----------------------------------------------------- |
|
22 |
-- Table `lenasys`.`Courses` |
|
23 |
-- ----------------------------------------------------- |
|
24 |
CREATE TABLE IF NOT EXISTS `lenasys`.`Courses` ( |
|
25 |
`courseID` VARCHAR(10) NOT NULL , |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
26 |
`name` VARCHAR(45) NULL , |
27 |
`courseData` VARCHAR(10) NULL , -- Short explenation about course, example: G1N 7,5hp |
|
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
28 |
PRIMARY KEY (`courseID`) , |
29 |
UNIQUE INDEX `courseID_UNIQUE` (`courseID` ASC) ) |
|
30 |
ENGINE = InnoDB; |
|
31 |
||
|
29.1.3
by b11johgu
changed the order on the tables. |
32 |
-- ----------------------------------------------------- |
33 |
-- Table `lenasys`.`StudentCourseRegistrations` |
|
34 |
-- ----------------------------------------------------- |
|
35 |
CREATE TABLE IF NOT EXISTS `lenasys`.`StudentCourseRegistrations` ( |
|
|
29.1.7
by b11johgu
fixed comments and an attribute |
36 |
`courseOccasion` VARCHAR(16) NOT NULL , -- Example HT2012 period 2 |
|
29.1.3
by b11johgu
changed the order on the tables. |
37 |
`userName` VARCHAR(20) NOT NULL , |
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
38 |
`courseID` VARCHAR(10) NOT NULL , -- Example G14234 |
39 |
PRIMARY KEY (`courseOccasion`,`userName`, `courseID`) , |
|
|
29.1.3
by b11johgu
changed the order on the tables. |
40 |
INDEX `fk_StudentCourseRegistrations_Courses1_idx` (`courseID` ASC) , |
41 |
CONSTRAINT `fk_StudentCourseRegistrations_Users` |
|
42 |
FOREIGN KEY (`userName` ) |
|
43 |
REFERENCES `lenasys`.`Users` (`userName` ) |
|
44 |
ON DELETE NO ACTION |
|
45 |
ON UPDATE NO ACTION, |
|
46 |
CONSTRAINT `fk_StudentCourseRegistrations_Courses1` |
|
47 |
FOREIGN KEY (`courseID` ) |
|
48 |
REFERENCES `lenasys`.`Courses` (`courseID` ) |
|
49 |
ON DELETE NO ACTION |
|
50 |
ON UPDATE NO ACTION) |
|
51 |
ENGINE = InnoDB; |
|
52 |
||
53 |
-- ----------------------------------------------------- |
|
54 |
-- Table `lenasys`.`Quizzes` |
|
55 |
-- ----------------------------------------------------- |
|
56 |
CREATE TABLE IF NOT EXISTS `lenasys`.`Quizzes` ( |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
57 |
`quizNr` INT NOT NULL , |
|
29.1.3
by b11johgu
changed the order on the tables. |
58 |
`courseID` VARCHAR(10) NOT NULL , |
59 |
`quizData` VARCHAR(45) NULL , |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
60 |
`allowMultipleReplies` BOOLEAN NULL , |
61 |
`autoCorrected` BOOLEAN NULL , -- if the quiz is corrected by auto or if the teacher needs to do it manually. |
|
62 |
`openingDate` DATETIME NULL , -- time for the student to do the quiz |
|
|
29.1.3
by b11johgu
changed the order on the tables. |
63 |
`closingDate` DATETIME NULL , |
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
64 |
PRIMARY KEY (`quizNr`, `courseID`) , |
|
29.1.3
by b11johgu
changed the order on the tables. |
65 |
INDEX `fk_Quizzes_Courses1_idx` (`courseID` ASC) , |
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
66 |
UNIQUE INDEX `quizNr_UNIQUE` (`quizNr` ASC) , |
|
29.1.3
by b11johgu
changed the order on the tables. |
67 |
CONSTRAINT `fk_Quizzes_Courses1` |
68 |
FOREIGN KEY (`courseID` ) |
|
69 |
REFERENCES `lenasys`.`Courses` (`courseID` ) |
|
70 |
ON DELETE NO ACTION |
|
71 |
ON UPDATE NO ACTION) |
|
72 |
ENGINE = InnoDB; |
|
73 |
||
74 |
-- ----------------------------------------------------- |
|
75 |
-- Table `lenasys`.`QuizQuestions` |
|
76 |
-- ----------------------------------------------------- |
|
77 |
CREATE TABLE IF NOT EXISTS `lenasys`.`QuizQuestions` ( |
|
|
29.1.5
by b11johgu
corrected the order of tables/attributes further |
78 |
`questionID` INT NOT NULL , -- The id of the individual question in the quiz. |
79 |
`quizNr` INT NOT NULL , -- The quiz from wich the question is from |
|
|
29.1.3
by b11johgu
changed the order on the tables. |
80 |
`courseID` VARCHAR(10) NOT NULL , |
|
29.1.5
by b11johgu
corrected the order of tables/attributes further |
81 |
`questionData` VARCHAR(45) NULL , -- the question |
82 |
`correctAnswer` VARCHAR(45) NULL , -- the answer |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
83 |
PRIMARY KEY (`questionID`, `quizNr`, `courseID`) , |
84 |
UNIQUE INDEX `questionID_UNIQUE` (`questionID` ASC) , |
|
85 |
INDEX `fk_QuizQuestions_Quizzes1_idx` (`quizNr` ASC, `courseID` ASC) , |
|
|
29.1.3
by b11johgu
changed the order on the tables. |
86 |
CONSTRAINT `fk_QuizQuestions_Quizzes1` |
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
87 |
FOREIGN KEY (`quizNr` , `courseID` ) |
88 |
REFERENCES `lenasys`.`Quizzes` (`quizNr` , `courseID` ) |
|
|
29.1.3
by b11johgu
changed the order on the tables. |
89 |
ON DELETE NO ACTION |
90 |
ON UPDATE NO ACTION) |
|
91 |
ENGINE = InnoDB; |
|
92 |
||
93 |
-- ----------------------------------------------------- |
|
94 |
-- Table `lenasys`.`AssignedQuizzes` |
|
95 |
-- ----------------------------------------------------- |
|
96 |
CREATE TABLE IF NOT EXISTS `lenasys`.`AssignedQuizzes` ( |
|
|
29.1.7
by b11johgu
fixed comments and an attribute |
97 |
`courseOccasion` VARCHAR(16) NOT NULL , -- Example HT2012 period 2 |
|
29.1.5
by b11johgu
corrected the order of tables/attributes further |
98 |
`userName` VARCHAR(20) NOT NULL , -- wich student took the quiz |
|
29.1.3
by b11johgu
changed the order on the tables. |
99 |
`courseID` VARCHAR(10) NOT NULL , |
100 |
`quizNr` INT NOT NULL , |
|
101 |
`quizCourseID` VARCHAR(10) NOT NULL , |
|
|
29.1.5
by b11johgu
corrected the order of tables/attributes further |
102 |
`answers` VARCHAR(45) NULL , -- answers provided by the student |
103 |
`answerHash` VARCHAR(45) NULL , -- a security measure |
|
104 |
`answeredTimeStamp` DATETIME NULL , -- when the student submittet the quiz |
|
|
29.1.3
by b11johgu
changed the order on the tables. |
105 |
`grade` VARCHAR(8) NULL , |
106 |
`gradeComment` VARCHAR(200) NULL , |
|
|
29.1.7
by b11johgu
fixed comments and an attribute |
107 |
PRIMARY KEY (`userName`, `courseID`, `quizNr`, `courseID`) , |
108 |
INDEX `fk_AssignedQuizzes_Quizzes1_idx` (`quizNr` ASC, `courseID` ASC) , |
|
|
29.1.3
by b11johgu
changed the order on the tables. |
109 |
CONSTRAINT `fk_AssignedQuizzes_StudentCourseRegistrations1` |
110 |
FOREIGN KEY (`courseOccasion`,`userName` , `courseID` ) |
|
111 |
REFERENCES `lenasys`.`StudentCourseRegistrations` (`courseOccasion`,`userName` , `courseID` ) |
|
112 |
ON DELETE NO ACTION |
|
113 |
ON UPDATE NO ACTION, |
|
114 |
CONSTRAINT `fk_AssignedQuizzes_Quizzes1` |
|
115 |
FOREIGN KEY (`quizNr` , `quizCourseID` ) |
|
116 |
REFERENCES `lenasys`.`Quizzes` (`quizNr` , `quizCourseID` ) |
|
117 |
ON DELETE NO ACTION |
|
118 |
ON UPDATE NO ACTION) |
|
119 |
ENGINE = InnoDB; |
|
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
120 |
|
121 |
-- ----------------------------------------------------- |
|
122 |
-- Table `lenasys`.`Examples` |
|
123 |
-- ----------------------------------------------------- |
|
124 |
CREATE TABLE IF NOT EXISTS `lenasys`.`Examples` ( |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
125 |
`exampleName` VARCHAR(20) NOT NULL , |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
126 |
`courseID` VARCHAR(10) NOT NULL , |
|
29.1.5
by b11johgu
corrected the order of tables/attributes further |
127 |
`orderNumber` INT NULL , -- the order of the examples in the same category |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
128 |
`description` VARCHAR(200) NULL , |
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
129 |
PRIMARY KEY (`exampleName`, `courseID`) , |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
130 |
INDEX `fk_Examples_Courses1_idx` (`courseID` ASC) , |
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
131 |
UNIQUE INDEX `exampleName_UNIQUE` (`exampleName` ASC) , |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
132 |
CONSTRAINT `fk_Examples_Courses1` |
133 |
FOREIGN KEY (`courseID` ) |
|
134 |
REFERENCES `lenasys`.`Courses` (`courseID` ) |
|
135 |
ON DELETE NO ACTION |
|
136 |
ON UPDATE NO ACTION) |
|
137 |
ENGINE = InnoDB; |
|
138 |
||
139 |
-- ----------------------------------------------------- |
|
140 |
-- Table `lenasys`.`Pages` |
|
141 |
-- ----------------------------------------------------- |
|
142 |
CREATE TABLE IF NOT EXISTS `lenasys`.`Pages` ( |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
143 |
`pageName` VARCHAR(45) NOT NULL , |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
144 |
`exampleName` VARCHAR(20) NOT NULL , |
145 |
`courseID` VARCHAR(10) NOT NULL , |
|
|
29.1.5
by b11johgu
corrected the order of tables/attributes further |
146 |
`orderNumber` INT NULL , |
147 |
`pageColumn` INT NOT NULL , -- which column in the view the file is presented |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
148 |
PRIMARY KEY (`pageName`, `exampleName`, `courseID`) , |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
149 |
INDEX `fk_Pages_Examples1_idx` (`exampleName` ASC, `courseID` ASC) , |
150 |
CONSTRAINT `fk_Pages_Examples1` |
|
151 |
FOREIGN KEY (`exampleName` , `courseID` ) |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
152 |
REFERENCES `lenasys`.`Examples` (`exampleName` , `courseID` ) |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
153 |
ON DELETE NO ACTION |
154 |
ON UPDATE NO ACTION) |
|
155 |
ENGINE = InnoDB; |
|
156 |
||
|
29.1.3
by b11johgu
changed the order on the tables. |
157 |
-- ----------------------------------------------------- |
158 |
-- Table `lenasys`.`Files` |
|
159 |
-- ----------------------------------------------------- |
|
160 |
CREATE TABLE IF NOT EXISTS `lenasys`.`Files` ( |
|
161 |
`fileName` VARCHAR(20) NOT NULL , |
|
|
29.1.5
by b11johgu
corrected the order of tables/attributes further |
162 |
`fileType` VARCHAR(5) NULL , -- can be for example: text, kod, video or bild |
163 |
`codeLanguage` VARCHAR(10) NULL , -- example: javascript, html, m.m. |
|
|
29.1.6
by b11johgu
added comment |
164 |
`dataBlob` BLOB NULL , -- This is where the binary file is stored. Searchable. |
|
29.1.3
by b11johgu
changed the order on the tables. |
165 |
PRIMARY KEY (`fileName`) , |
166 |
UNIQUE INDEX `fileName_UNIQUE` (`fileName` ASC) ) |
|
167 |
ENGINE = InnoDB; |
|
168 |
||
169 |
||
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
170 |
|
171 |
-- ----------------------------------------------------- |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
172 |
-- Table `lenasys`.`PageFiles` |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
173 |
-- ----------------------------------------------------- |
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
174 |
CREATE TABLE IF NOT EXISTS `lenasys`.`PageFiles` ( |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
175 |
`fileName` VARCHAR(20) NOT NULL , |
|
29.1.5
by b11johgu
corrected the order of tables/attributes further |
176 |
`pageName` VARCHAR(45) NOT NULL , -- |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
177 |
`exampleName` VARCHAR(20) NOT NULL , |
178 |
`courseID` VARCHAR(10) NOT NULL , |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
179 |
PRIMARY KEY (`fileName`, `pageName`, `exampleName`, `courseID`) , |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
180 |
INDEX `fk_PagesFiles_Files1_idx` (`fileName` ASC) , |
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
181 |
INDEX `fk_PagesFiles_Pages1_idx` (`pageName` ASC, `exampleName` ASC, `courseID` ASC) , |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
182 |
CONSTRAINT `fk_PagesFiles_Files1` |
183 |
FOREIGN KEY (`fileName` ) |
|
184 |
REFERENCES `lenasys`.`Files` (`fileName` ) |
|
185 |
ON DELETE NO ACTION |
|
186 |
ON UPDATE NO ACTION, |
|
187 |
CONSTRAINT `fk_PagesFiles_Pages1` |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
188 |
FOREIGN KEY (`pageName` , `exampleName` , `courseID` ) |
189 |
REFERENCES `lenasys`.`Pages` (`pageName` , `exampleName` , `courseID` ) |
|
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
190 |
ON DELETE NO ACTION |
191 |
ON UPDATE NO ACTION) |
|
192 |
ENGINE = InnoDB; |
|
193 |
||
194 |
||
195 |
-- ----------------------------------------------------- |
|
196 |
-- Table `lenasys`.`FileKeywords` |
|
197 |
-- ----------------------------------------------------- |
|
198 |
CREATE TABLE IF NOT EXISTS `lenasys`.`FileKeywords` ( |
|
199 |
`id` INT NOT NULL AUTO_INCREMENT , |
|
200 |
`fileName` VARCHAR(20) NOT NULL , |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
201 |
`keyword` VARCHAR(20) NOT NULL , |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
202 |
PRIMARY KEY (`id`, `fileName`) , |
203 |
INDEX `fk_FileKeywords_Files1_idx` (`fileName` ASC) , |
|
204 |
UNIQUE INDEX `id_UNIQUE` (`id` ASC) , |
|
205 |
CONSTRAINT `fk_FileKeywords_Files1` |
|
206 |
FOREIGN KEY (`fileName` ) |
|
207 |
REFERENCES `lenasys`.`Files` (`fileName` ) |
|
208 |
ON DELETE NO ACTION |
|
209 |
ON UPDATE NO ACTION) |
|
210 |
ENGINE = InnoDB; |
|
211 |
||
212 |
||
213 |
-- ----------------------------------------------------- |
|
214 |
-- Table `lenasys`.`FileInterestingLines` |
|
215 |
-- ----------------------------------------------------- |
|
216 |
CREATE TABLE IF NOT EXISTS `lenasys`.`FileInterestingLines` ( |
|
217 |
`id` INT NOT NULL AUTO_INCREMENT , |
|
218 |
`fileName` VARCHAR(20) NOT NULL , |
|
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
219 |
`beginAt` INT NULL , |
220 |
`endAt` INT NULL , |
|
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
221 |
PRIMARY KEY (`id`, `fileName`) , |
222 |
INDEX `fk_FileInterestingLines_Files1_idx` (`fileName` ASC) , |
|
223 |
UNIQUE INDEX `id_UNIQUE` (`id` ASC) , |
|
224 |
CONSTRAINT `fk_FileInterestingLines_Files1` |
|
225 |
FOREIGN KEY (`fileName` ) |
|
226 |
REFERENCES `lenasys`.`Files` (`fileName` ) |
|
227 |
ON DELETE NO ACTION |
|
228 |
ON UPDATE NO ACTION) |
|
229 |
ENGINE = InnoDB; |
|
230 |
||
|
29.1.7
by b11johgu
fixed comments and an attribute |
231 |
|
232 |
||
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
233 |
USE `lenasys` ; |
234 |
||
|
29.1.4
by b11johgu
changed the order of the attributes in the tables. |
235 |
-- allow maximum of 5 succesfull quiz-attemps is a good begining for implementation of the loggingtables to add restriction. |
|
28.1.1
by b11johgu
added a new .sql to test alongside with the old. |
236 |
SET SQL_MODE=@OLD_SQL_MODE; |
237 |
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; |
|
|
29.1.7
by b11johgu
fixed comments and an attribute |
238 |
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; |