-
Notifications
You must be signed in to change notification settings - Fork 2
/
schema.sql
51 lines (43 loc) · 1.18 KB
/
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
DROP DATABASE IF EXISTS food_swap;
CREATE DATABASE food_swap;
\connect food_swap;
CREATE TABLE users_auth (
id SERIAL,
password VARCHAR(256) NOT NULL,
salt VARCHAR(256) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE users (
id SERIAL,
user_auth_id INTEGER NOT NULL REFERENCES users_auth(id),
name VARCHAR(25) NOT NULL,
username VARCHAR(25) NOT NULL,
picture VARCHAR(255) NULL DEFAULT NULL,
email VARCHAR(255) NOT NULL,
bio VARCHAR(255) NULL DEFAULT NULL,
latitude Float NULL DEFAULT NULL,
longitude Float NULL DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE TABLE food (
id SERIAL,
user_id INTEGER NOT NULL REFERENCES users(id),
dishName VARCHAR(25) NULL DEFAULT NULL,
description VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE TABLE friends (
id SERIAL,
user_id1 INTEGER NOT NULL REFERENCES users(id),
user_id2 INTEGER NOT NULL REFERENCES users(id),
PRIMARY KEY (id)
);
CREATE TABLE trade (
id SERIAL,
user_id1 INTEGER NOT NULL REFERENCES users(id),
food_id1 INTEGER NOT NULL REFERENCES food(id),
user_id2 INTEGER NOT NULL REFERENCES users(id),
food_id2 INTEGER NOT NULL REFERENCES food(id),
status BOOLEAN DEFAULT NULL,
PRIMARY KEY (id)
);