-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.sql
79 lines (61 loc) · 2.33 KB
/
db.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
CREATE TABLE `tsh_user` (
`id` CHAR(36) PRIMARY KEY,
`branch_id` CHAR(36) NOT NULL,
`user_name` CHAR(255) NOT NULL,
`password` CHAR(36) NOT NULL,
`role` ENUM ('event_organizer', 'administrator', 'student', 'student_comitee', 'guest') NOT NULL,
`email` VARCHAR(100) NOT NULL
);
CREATE TABLE `event_participance` (
`id` CHAR(36) PRIMARY KEY,
`user_id` CHAR(36) NOT NULL,
`event_id` CHAR(36) NOT NULL,
`state` ENUM ('signed', 'present', 'late', 'missed') NOT NULL
);
CREATE TABLE `event` (
`id` CHAR(36) PRIMARY KEY,
`branch_id` CHAR(36) NOT NULL,
`title` VARCHAR(200) NOT NULL,
`description` VARCHAR(4000) NOT NULL,
`venue` VARCHAR(255) DEFAULT NULL
);
CREATE TABLE `paid_event` (
`timed_event_id` CHAR(36) PRIMARY KEY NOT NULL,
`max_participants` smallint DEFAULT NULL,
`price` smallint NOT NULL
);
CREATE TABLE `timed_event` (
`event_id` CHAR(36) PRIMARY KEY NOT NULL,
`start` datetime NOT NULL,
`end` datetime DEFAULT NULL
);
CREATE TABLE `branch` (
`id` CHAR(36) PRIMARY KEY,
`branch_name` VARCHAR(255) NOT NULL
);
CREATE TABLE `event_suggestion` (
`id` CHAR(36) PRIMARY KEY,
`user_id` CHAR(36) NOT NULL,
`branch_id` CHAR(36) NOT NULL,
`title` VARCHAR(200) NOT NULL,
`description` VARCHAR(4000) NOT NULL,
`venue` VARCHAR(255) DEFAULT NULL
);
CREATE TABLE `image_user_tag` (
`image_path` CHAR(36) NOT NULL,
`user_id` CHAR(36) NOT NULL
);
CREATE TABLE `image_event_tag` (
`image_path` CHAR(36) NOT NULL,
`event_id` CHAR(36) NOT NULL
);
ALTER TABLE `event_participance` ADD FOREIGN KEY (`user_id`) REFERENCES `tsh_user` (`id`);
ALTER TABLE `event_participance` ADD FOREIGN KEY (`event_id`) REFERENCES `event` (`id`);
ALTER TABLE `tsh_user` ADD FOREIGN KEY (`branch_id`) REFERENCES `branch` (`id`);
ALTER TABLE `timed_event` ADD FOREIGN KEY (`event_id`) REFERENCES `event` (`id`);
ALTER TABLE `paid_event` ADD FOREIGN KEY (`timed_event_id`) REFERENCES `timed_event` (`event_id`);
ALTER TABLE `event` ADD FOREIGN KEY (`branch_id`) REFERENCES `branch` (`id`);
ALTER TABLE `event_suggestion` ADD FOREIGN KEY (`user_id`) REFERENCES `tsh_user` (`id`);
ALTER TABLE `event_suggestion` ADD FOREIGN KEY (`branch_id`) REFERENCES `branch` (`id`);
ALTER TABLE `image_user_tag` ADD FOREIGN KEY (`user_id`) REFERENCES `tsh_user` (`id`);
ALTER TABLE `image_event_tag` ADD FOREIGN KEY (`event_id`) REFERENCES `event` (`id`);