-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
166 lines (147 loc) · 5.29 KB
/
schema.sql
File metadata and controls
166 lines (147 loc) · 5.29 KB
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
CREATE TABLE brands(
b_id int generated always as identity not null PRIMARY KEY,
created_at timestamp with time zone null default now(),
name text not null,
service_type text not null
);
CREATE TABLE food(
f_id int generated always as identity not null PRIMARY KEY,
brand_id int not null,
FOREIGN KEY (brand_id) REFERENCES Brands(b_id),
created_at timestamp with time zone null default now(),
name text not null
);
CREATE TABLE categories(
food_id int not null,
FOREIGN KEY (food_id) REFERENCES food(f_id),
created_at timestamp with time zone null default now(),
category text not null
);
CREATE TABLE locations(
l_id int generated always as identity not null PRIMARY KEY,
brand_id int not null,
FOREIGN KEY (brand_id) REFERENCES Brands(b_id),
created_at timestamp with time zone null default now(),
address text not null
);
CREATE TYPE dayofweek AS ENUM ('sad', 'ok', 'happy');
CREATE TABLE hours(
id int generated always as identity not null PRIMARY KEY,
created_at timestamp with time zone null default now(),
location_id int not null,
FOREIGN KEY (location_id) REFERENCES locations(l_id),
day_name day_of_week not null,
open_time time DEFAULT '00:00:00',
close_time time DEFAULT '24:00:00'
);
CREATE TABLE users(
u_id int generated always as identity not null PRIMARY KEY,
created_at timestamp with time zone null default now(),
name text not null
);
CREATE TABLE reviews(
r_id int generated always as identity not null PRIMARY KEY,
location_id int not null,
FOREIGN KEY (location_id) REFERENCES Locations(l_id),
date_published timestamp with time zone null default now(),
publisher_id int not null REFERENCES Users(u_id),
service_rating int not null,
quality_rating int not null,
cleanliness_rating int not null,
description text not null
);
CREATE TABLE user_visits(
v_id int generated always as identity not null PRIMARY KEY,
created_at timestamp with time zone null default now(),
user_id int not null,
FOREIGN KEY (user_id) REFERENCES users(u_id),
FOREIGN KEY (location_id) REFERENCES locations(l_id),
);
-- This is where a set of default values will be initialized
-- like McDonalds and the on maddona rd
-- every table has at least 1 starting value, including reviews
INSERT INTO brands (name, service_type)
VALUES ('McDonalds', 'Fast Food'),
('Del Taco', 'Fast Food'),
('Dominos', 'Pizza Delivery'),
('Five Guys', 'Fast Food');
INSERT INTO food (brand_id, name)
VALUES (1, 'Big Mac'),
(1, 'Fries'),
(2, 'The Del Taco'),
(2, 'Crinkle-Cut Fries'),
(3, 'Meat Lovers'),
(3, 'Pepperoni'),
(4, 'Single Cheeseburger'),
(4, 'Cajun Fries');
INSERT INTO categories (food_id, category)
VALUES (1, 'Burger'),
(2, 'Side'),
(3, 'Taco'),
(4, 'Side'),
(5, 'Pizza'),
(6, 'Pizza'),
(7, 'Burger'),
(8, 'Side');
INSERT INTO locations (brand_id, address)
VALUES (1, '275 Madonna Rd, San Luis Obispo, CA 93401'),
(1, '123 Bob Dr, Tustin, CA 92780'),
(2, '13742 Red Hill Ave, Tustin, CA 92780'),
(3, '866 Foothill Blvd, San Luis Obispo, CA 93405'),
(4, '763 Foothill Blvd, San Luis Obispo, CA 93405'),
(1, '350 5 Cities Dr, Pismo Beach, CA 93449'),
(1, '1550 W Grand Ave, Grover Beach, CA 93433');
INSERT INTO hours (business_id, day_of_week, open_time, close_time)
VALUES (1, 'Monday', '00:00:00', '24:00:00'),
(1, 'Tuesday', '00:00:00', '24:00:00'),
(1, 'Wednesday', '00:00:00', '24:00:00'),
(1, 'Thursday', '00:00:00', '24:00:00'),
(1, 'Friday', '00:00:00', '24:00:00'),
(1, 'Saturday', '00:00:00', '24:00:00'),
(1, 'Sunday', '00:00:00', '24:00:00'),
(2, 'Monday', '07:00:00', '22:00:00'),
(2, 'Tuesday', '07:00:00', '22:00:00'),
(2, 'Wednesday', '07:00:00', '22:00:00'),
(2, 'Thursday', '07:00:00', '22:00:00'),
(2, 'Friday', '07:00:00', '24:00:00'),
(2, 'Saturday', '08:00:00', '02:00:00'),
(2, 'Sunday', '08:00:00', '22:00:00'),
(3, 'Monday', '00:00:00', '24:00:00'),
(3, 'Tuesday', '00:00:00', '24:00:00'),
(3, 'Wednesday', '00:00:00', '24:00:00'),
(3, 'Thursday', '00:00:00', '24:00:00'),
(3, 'Friday', '00:00:00', '24:00:00'),
(3, 'Saturday', '00:00:00', '24:00:00'),
(3, 'Sunday', '00:00:00', '24:00:00'),
(4, 'Monday', '11:00:00', '02:00:00'),
(4, 'Tuesday', '11:00:00', '02:00:00'),
(4, 'Wednesday', '11:00:00', '02:00:00'),
(4, 'Thursday', '11:00:00', '02:00:00'),
(4, 'Friday', '11:00:00', '02:00:00'),
(4, 'Saturday', '11:00:00', '02:00:00'),
(4, 'Sunday', '11:00:00', '02:00:00'),
(5, 'Monday', '11:00:00', '22:00:00'),
(5, 'Tuesday', '11:00:00', '22:00:00'),
(5, 'Wednesday', '11:00:00', '22:00:00'),
(5, 'Thursday', '11:00:00', '22:00:00'),
(5, 'Friday', '11:00:00', '22:00:00'),
(5, 'Saturday', '11:00:00', '22:00:00'),
(5, 'Sunday', '11:00:00', '22:00:00');
INSERT INTO users (name)
VALUES ('Anonymous'),
('Karen Willoughby'),
('Randy Jr'),
('Meaty Marley'),
('Jonathan Martin'),
('Carlos Lopez'),
('Willeam Mendez'),
('Justin Timberlake'),
('The Creature'),
('Cassidy');
INSERT INTO reviews(location_id, publisher_id,
service_rating, quality_rating, cleanliness_rating, description)
VALUES (1, 1, 0, 0, 0, 'Complete garbage, will never go here again'),
(4, 1, 10, 10, 10, 'Best Dominos Ever. took less than 10 min from ordering to get food, it was somehow better than other dominos I have gone too AND was spotless down to the area behind the drinks.');
INSERT INTO visited (user_id, visit)
VALUES (1, '275 Madonna Rd, San Luis Obispo, CA 93401'),
(1, '866 Foothill Blvd, San Luis Obispo, CA 93405');