-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
31 lines (23 loc) · 885 Bytes
/
schema.sql
File metadata and controls
31 lines (23 loc) · 885 Bytes
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
DROP DATABASE IF EXISTS restaurant_reviews;
CREATE DATABASE restaurant_reviews;
\connect restaurant_reviews;
CREATE TABLE restaurant (
restaurant_id serial NOT NULL PRIMARY KEY,
name text NOT NULL
);
CREATE TABLE reviews (
reviews_id serial NOT NULL PRIMARY KEY,
user_name text NOT NULL,
dined_date text NOT NULL,
rating integer NOT NULL,
city text NOT NULL,
reviews text NOT NULL,
restaurant_id INT REFERENCES restaurant (restaurant_id)
);
-- CREATE TABLE joined_table (
-- reviews_id INT REFERENCES reviews (reviews_id) ON UPDATE CASCADE ON DELETE CASCADE,
-- restaurant_id INT REFERENCES restaurant (restaurant_id) on UPDATE CASCADE,
-- CONSTRAINT restaurant_reviewsJOIN PRIMARY KEY (reviews_id, restaurant_id)
-- );
-- INSERT INTO reviews (city, dined_date, description , rating, review ) VALUES
-- psql postgres restaurant_reviews < schema.sql