-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase_schema.sql
143 lines (134 loc) · 4.97 KB
/
database_schema.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
CREATE DATABASE `happy_hour`;
USE `happy_hour`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`first_name` varchar(50) DEFAULT NULL,
`last_name` varchar(50) DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`email` varchar(256) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username_unique` (`username`),
KEY `user_username_index` (`username`),
KEY `user_email_index` (`email`),
KEY `created_at_idx` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=6106664 DEFAULT CHARSET=latin1;
CREATE TABLE `venue` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`address` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`address2` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`city` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`state` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`zip` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`country` varchar(5) CHARACTER SET utf8 DEFAULT NULL,
`image` text COLLATE utf8_unicode_ci DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_unique` (`name`),
KEY `venue_name_index` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `venue_list` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `venue_lists` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`venue_id` int(11) NOT NULL,
`venue_list_id` int(11) NOT NULL,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (venue_id)
REFERENCES venue(id)
ON DELETE CASCADE,
FOREIGN KEY (venue_list_id)
REFERENCES venue_list(id)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `user_favorites` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`venue_id` int(11) NOT NULL,
`user_id` varchar(100) NOT NULL,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (venue_id)
REFERENCES venue(id)
ON DELETE CASCADE,
UNIQUE INDEX `user_favorite_unique` (`venue_id`, `user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `menu` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`venue_id` int(11) NOT NULL,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (venue_id)
REFERENCES venue(id)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `menu_item` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`menu_id` int(11) NOT NULL,
`category` enum('drink','food','all') COLLATE utf8_unicode_ci DEFAULT NULL,
`price` double DEFAULT NULL,
`description` text COLLATE utf8_unicode_ci,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (menu_id)
REFERENCES menu(id)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `notification` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`list_id` int(11) DEFAULT NULL,
`favorites_id` int(11) DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`frequency` enum('daily','weekly','monthly') COLLATE utf8_unicode_ci DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (list_id)
REFERENCES venue_list(id),
FOREIGN KEY (favorites_id)
REFERENCES user_favorites(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `user_notifications` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`notification_id` int(11) NOT NULL,
`email` varchar(256) NOT NULL,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (user_id)
REFERENCES user(id)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `menu_datetime` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`menu_id` int(11) NOT NULL,
`mon` tinyint(1) DEFAULT '0',
`tue` tinyint(1) DEFAULT '0',
`wed` tinyint(1) DEFAULT '0',
`thu` tinyint(1) DEFAULT '0',
`fri` tinyint(1) DEFAULT '0',
`sat` tinyint(1) DEFAULT '0',
`sunday` tinyint(1) DEFAULT '0',
`start_at` timestamp DEFAULT 0,
`end_at` timestamp DEFAULT 0,
`updated_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (menu_id)
REFERENCES menu(id)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;