-
Notifications
You must be signed in to change notification settings - Fork 0
/
degree.sql
165 lines (144 loc) · 5.14 KB
/
degree.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
CREATE SCHEMA IF NOT EXISTS `degree` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `degree` ;
-- -----------------------------------------------------
-- Table `degree`.`participant`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `degree`.`participant` (
`id` INT NOT NULL AUTO_INCREMENT ,
`fname` VARCHAR(45) NULL ,
`lname` VARCHAR(45) NULL ,
`token` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `degree`.`device`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `degree`.`device` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NULL ,
`type` ENUM('phone','tablet') NULL ,
`xres` INT NULL ,
`yres` INT NULL ,
`diagonal` FLOAT NULL ,
`os` VARCHAR(45) NULL ,
`version` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `degree`.`session`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `degree`.`session` (
`id` INT NOT NULL AUTO_INCREMENT ,
`participant_id` INT NOT NULL ,
`device_id` INT NOT NULL ,
`date` DATE NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_session_participant_idx` (`participant_id` ASC) ,
INDEX `fk_session_device1_idx` (`device_id` ASC) ,
CONSTRAINT `fk_session_participant`
FOREIGN KEY (`participant_id` )
REFERENCES `degree`.`participant` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_session_device1`
FOREIGN KEY (`device_id` )
REFERENCES `degree`.`device` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `degree`.`text`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `degree`.`text` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NULL ,
`description` TINYTEXT NULL ,
`body` TEXT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `degree`.`stage`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `degree`.`stage` (
`id` INT NOT NULL AUTO_INCREMENT ,
`status` ENUM('started','in progress','bailed','finished') NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `degree`.`reading`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `degree`.`reading` (
`id` INT NOT NULL AUTO_INCREMENT ,
`text_id` INT NOT NULL ,
`stage_id` INT NOT NULL ,
`start` TIME NULL ,
`end` TIME NULL ,
`presentation` ENUM('crawl','paragraph') NULL ,
`angle` FLOAT NULL ,
`speed` TINYINT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_reading_text1_idx` (`text_id` ASC) ,
INDEX `fk_reading_stage1_idx` (`stage_id` ASC) ,
CONSTRAINT `fk_reading_text1`
FOREIGN KEY (`text_id` )
REFERENCES `degree`.`text` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_reading_stage1`
FOREIGN KEY (`stage_id` )
REFERENCES `degree`.`stage` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `degree`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `degree`.`user` (
`id` INT NOT NULL AUTO_INCREMENT ,
`uname` VARCHAR(45) NOT NULL ,
`pword` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `degree`.`session_stage`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `degree`.`session_stage` (
`session_id` INT NULL ,
`stage_id` INT NULL ,
PRIMARY KEY (`stage_id`, `session_id`) ,
INDEX `fk_session_stage_stage1_idx` (`stage_id` ASC) ,
INDEX `fk_session_stage_session1_idx` (`session_id` ASC) ,
CONSTRAINT `fk_session_stage_session1`
FOREIGN KEY (`session_id` )
REFERENCES `degree`.`session` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_session_stage_stage1`
FOREIGN KEY (`stage_id` )
REFERENCES `degree`.`stage` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `degree`.`metric`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `degree`.`metric` (
`id` INT NOT NULL AUTO_INCREMENT ,
`reading_id` INT NOT NULL ,
`type` ENUM('distance','errors') NULL ,
`value` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_metric_reading1_idx` (`reading_id` ASC) ,
CONSTRAINT `fk_metric_reading1`
FOREIGN KEY (`reading_id` )
REFERENCES `degree`.`reading` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
USE `degree` ;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;