-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
77 lines (72 loc) · 1.97 KB
/
database.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
/* Users table */
CREATE TABLE users (
id tinyint(3) unsigned auto_increment,
email varchar(255),
password char(128),
name varchar(64),
access_level tinyint(1) unsigned,
token char(64),
session char(64),
PRIMARY KEY (id)
);
/* Projects table */
CREATE TABLE projects (
id tinyint(3) unsigned auto_increment,
user_id tinyint(3) unsigned,
title varchar(255),
description varchar(511),
glossary text(4095),
added timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
/* Source segments table */
CREATE TABLE source_segments (
id smallint(5) unsigned auto_increment,
project_id tinyint(3) unsigned,
text text(50000),
PRIMARY KEY (id),
FOREIGN KEY (project_id) REFERENCES projects(id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
/* Target segments table */
CREATE TABLE target_segments (
id smallint(5) unsigned,
project_id tinyint(3) unsigned,
user_id tinyint(3) unsigned,
text text(50000),
complete tinyint(1) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (project_id) REFERENCES projects(id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
/* How would you translate x? queries*/
CREATE TABLE requests (
id mediumint(8) unsigned auto_increment,
user_id tinyint(3) unsigned,
/*project_id tinyint(3) unsigned,*/
segment_id smallint(5) unsigned,
context text(4095),
text varchar(1023),
open tinyint(1) unsigned NOT NULL,
added timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (segment_id) REFERENCES source_segments(id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
/* Answers table */
CREATE TABLE answers (
id int(10) unsigned auto_increment,
user_id tinyint(3) unsigned,
/*project_id tinyint(3) unsigned,
segment_id smallint(5) unsigned,*/
request_id mediumint(8) unsigned,
text varchar(1023),
added timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (request_id) REFERENCES requests(id)
ON DELETE CASCADE
ON UPDATE CASCADE
);