-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
35 lines (33 loc) · 748 Bytes
/
Copy pathdatabase.sql
File metadata and controls
35 lines (33 loc) · 748 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
30
31
32
33
34
35
/*
@Table users
*/
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
name VARCHAR(155) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL
);
/*
@Table books
*/
CREATE TABLE IF NOT EXISTS books (
id SERIAL PRIMARY KEY,
title VARCHAR (155) NOT NULL,
description TEXT NOT NULL,
created_at TIMESTAMP NOT NULL,
user_id INT NOT NULL,
FOREIGN KEY (user_id) REFERENCES users (id)
);
/*
@Table images
*/
CREATE TABLE IF NOT EXISTS images (
id SERIAL PRIMARY KEY,
image BYTEA NOT NULL,
created_at TIMESTAMP NOT NULL,
book_id INT NOT NULL,
user_id INT NOT NULL,
FOREIGN KEY (book_id) REFERENCES books (id),
FOREIGN KEY (user_id) REFERENCES users (id)
);