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