-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
232 lines (209 loc) · 9.29 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
-- MySQL dump 10.13 Distrib 5.7.9, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: pia_projekat_feb
-- ------------------------------------------------------
-- Server version 5.7.14
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `event`
--
DROP TABLE IF EXISTS `event`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `event` (
`event_id` int(11) NOT NULL AUTO_INCREMENT,
`event_name` varchar(100) CHARACTER SET latin1 NOT NULL,
`event_place` varchar(100) CHARACTER SET latin1 NOT NULL,
`start_date` date NOT NULL,
`end_date` date NOT NULL,
`one_day_ticket_price` decimal(10,0) NOT NULL,
`all_days_ticket_price` decimal(10,0) NOT NULL,
`max_reservations_per_user` smallint(6) NOT NULL,
`max_tickets_available_per_day` int(11) NOT NULL,
`view_count` int(11) NOT NULL DEFAULT '0',
`sell_count` int(11) NOT NULL DEFAULT '0',
`cancelled` tinyint(1) NOT NULL DEFAULT '0',
`rating` float NOT NULL DEFAULT '0',
PRIMARY KEY (`event_id`)
) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `image`
--
DROP TABLE IF EXISTS `image`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `image` (
`image_id` int(11) NOT NULL AUTO_INCREMENT,
`event_id` int(11) NOT NULL,
`image_url` varchar(300) CHARACTER SET latin1 NOT NULL,
`approved` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`image_id`),
KEY `image_event_idx` (`event_id`),
CONSTRAINT `image_event` FOREIGN KEY (`event_id`) REFERENCES `event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `message`
--
DROP TABLE IF EXISTS `message`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `message` (
`message_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`event_id` int(11) NOT NULL,
`type` enum('reserved','sold','performer','timetable') CHARACTER SET latin1 NOT NULL,
PRIMARY KEY (`message_id`),
KEY `message_event_idx` (`event_id`),
KEY `message_user_idx` (`user_id`),
CONSTRAINT `message_event` FOREIGN KEY (`event_id`) REFERENCES `event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `message_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `performer`
--
DROP TABLE IF EXISTS `performer`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `performer` (
`performer_id` int(11) NOT NULL AUTO_INCREMENT,
`event_id` int(11) NOT NULL,
`performer_name` varchar(200) CHARACTER SET latin1 NOT NULL,
`start_time` datetime(6) NOT NULL,
`end_time` datetime(6) NOT NULL,
PRIMARY KEY (`performer_id`),
KEY `performer_event_idx` (`event_id`),
CONSTRAINT `performer_event` FOREIGN KEY (`event_id`) REFERENCES `event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=237 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `reservation`
--
DROP TABLE IF EXISTS `reservation`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `reservation` (
`reservation_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`event_id` int(11) NOT NULL,
`status` enum('pending','sold','cancelled_by_user','failed') CHARACTER SET latin1 NOT NULL,
`reservation_datetime` datetime NOT NULL,
`type` enum('one_day','whole') CHARACTER SET latin1 NOT NULL,
`cancelled_event` tinyint(1) NOT NULL DEFAULT '0',
`day_selected` int(11) DEFAULT '0',
PRIMARY KEY (`reservation_id`),
KEY `reservation_user_idx` (`user_id`),
KEY `reservation_event_idx` (`event_id`),
CONSTRAINT `reservation_event` FOREIGN KEY (`event_id`) REFERENCES `event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `reservation_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `social_link`
--
DROP TABLE IF EXISTS `social_link`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `social_link` (
`social_link_id` int(11) NOT NULL AUTO_INCREMENT,
`event_id` int(11) NOT NULL,
`network_name` varchar(30) CHARACTER SET latin1 NOT NULL,
`url` varchar(300) CHARACTER SET latin1 NOT NULL,
PRIMARY KEY (`social_link_id`),
KEY `social_event_idx` (`event_id`),
CONSTRAINT `social_event` FOREIGN KEY (`event_id`) REFERENCES `event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=227 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tickets_remaining`
--
DROP TABLE IF EXISTS `tickets_remaining`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tickets_remaining` (
`event_id` int(11) NOT NULL,
`event_day` int(11) NOT NULL,
`available` int(11) NOT NULL,
PRIMARY KEY (`event_id`,`event_day`),
CONSTRAINT `tickets_event` FOREIGN KEY (`event_id`) REFERENCES `event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
`last_name` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
`username` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
`password` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
`phone` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
`e-mail` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
`status` enum('pending','regular','blocked','refused') CHARACTER SET latin1 DEFAULT NULL,
`last_login_time` timestamp NULL DEFAULT NULL,
`fb_id` varchar(2000) CHARACTER SET latin1 DEFAULT NULL,
`g_id` varchar(2000) CHARACTER SET latin1 DEFAULT NULL,
`admin` tinyint(1) NOT NULL DEFAULT '0',
`failed_reservations` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `e-mail` (`e-mail`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user_review`
--
DROP TABLE IF EXISTS `user_review`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_review` (
`review_id` int(11) NOT NULL AUTO_INCREMENT,
`event_name` varchar(100) CHARACTER SET latin1 NOT NULL,
`user_id` int(11) NOT NULL,
`comment` text CHARACTER SET latin1,
`rating` tinyint(4) DEFAULT NULL,
`review_time` datetime(6) DEFAULT NULL,
PRIMARY KEY (`review_id`),
KEY `review_user_idx` (`user_id`),
CONSTRAINT `review_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `video`
--
DROP TABLE IF EXISTS `video`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `video` (
`video_id` int(11) NOT NULL AUTO_INCREMENT,
`event_id` int(11) NOT NULL,
`video_url` varchar(300) CHARACTER SET latin1 NOT NULL,
`approved` tinyint(1) NOT NULL,
PRIMARY KEY (`video_id`),
KEY `video_event_idx` (`event_id`),
CONSTRAINT `video_event` FOREIGN KEY (`event_id`) REFERENCES `event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-02-19 19:51:03