-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_tables.sql
60 lines (49 loc) · 996 Bytes
/
init_tables.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
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
user_name TEXT,
email TEXT,
password TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS collection (
id SERIAL PRIMARY KEY,
user_id INT,
book_id INT,
user_cover TEXT,
num_pages INT,
pages_completed INT,
date_added DATE,
date_completed DATE
);
CREATE TABLE IF NOT EXISTS notes (
id SERIAL PRIMARY KEY,
user_id INT,
description TEXT,
book_id INT,
private BOOLEAN,
date DATE
);
CREATE TABLE IF NOT EXISTS books (
id SERIAL PRIMARY KEY,
book_cover TEXT,
title TEXT,
description TEXT
);
CREATE TABLE IF NOT EXISTS book_authors (
id SERIAL PRIMARY KEY,
book_id INT,
author_id INT
);
CREATE TABLE IF NOT EXISTS authors (
id SERIAL PRIMARY KEY,
author_name TEXT
);
CREATE TABLE IF NOT EXISTS book_genres (
id SERIAL PRIMARY KEY,
book_id INT,
genre_id INT
);
CREATE TABLE IF NOT EXISTS genres (
id SERIAL PRIMARY KEY,
genre_name TEXT
);