-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtables.sql
More file actions
73 lines (66 loc) · 1.81 KB
/
Copy pathtables.sql
File metadata and controls
73 lines (66 loc) · 1.81 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
CREATE TABLE
IF NOT EXISTS locations(
location_id SERIAL PRIMARY KEY,
location_name TEXT,
location_icon TEXT
);
CREATE TABLE IF NOT EXISTS users (
user_id SERIAL PRIMARY KEY,
username VARCHAR(15),
user_pw TEXT,
user_displayname VARCHAR(25),
location_id INTEGER,
user_img TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
FOREIGN KEY (location_id) REFERENCES locations(location_id)
);
CREATE TABLE IF NOT EXISTS artists(
artist_id SERIAL PRIMARY KEY,
artist_username VARCHAR (15),
artist_displayname VARCHAR (25),
artist_pw TEXT,
location_id INTEGER,
email TEXT,
booking_avail BOOLEAN,
artist_img TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
FOREIGN KEY
(location_id) REFERENCES locations
(location_id)
);
CREATE TABLE IF NOT EXISTS hashtags(
hashtag_id SERIAL PRIMARY KEY,
hashtag_name VARCHAR (25)
);
CREATE TABLE IF NOT EXISTS tattoos(
tattoo_id SERIAL PRIMARY KEY,
artist_id INTEGER,
tattoo_img TEXT,
created_at TIMESTAMPTZ
NOT NULL DEFAULT NOW
(),
updated_at TIMESTAMPTZ
NOT NULL DEFAULT NOW
(),
FOREIGN KEY (artist_id) REFERENCES artists(artist_id)
);
CREATE TABLE IF NOT EXISTS artists_hashtags(
ah_id SERIAL PRIMARY KEY,
artist_id INTEGER,
hashtag_id INTEGER,
FOREIGN KEY (artist_id) REFERENCES artists(artist_id),
FOREIGN KEY (hashtag_id) REFERENCES hashtags(hashtag_id)
);
CREATE TABLE
IF NOT EXISTS tattoos_hashtags
(
th_id SERIAL PRIMARY KEY,
tattoo_id INTEGER,
hashtag_id INTEGER,
FOREIGN KEY (tattoo_id) REFERENCES tattoos
(tattoo_id),
FOREIGN KEY (hashtag_id) REFERENCES hashtags
(hashtag_id)
);