-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshema.sql
59 lines (49 loc) · 1.15 KB
/
shema.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
58
CREATE DATABASE catalog;
CREATE TABLE authors (
id INT GENERATED ALWAYS AS IDENTITY,
first_name VARCHAR(100),
last_name VARCHAR(100),
PRIMARY KEY(id)
);
CREATE TABLE genres (
id INT GENERATED ALWAYS AS IDENTITY,
name VARCHAR(100),
PRIMARY KEY(id)
);
CREATE TABLE labels (
id INT GENERATED ALWAYS AS IDENTITY,
title VARCHAR(100),
color VARCHAR(100),
PRIMARY KEY(id)
);
CREATE TABLE item (
id INT GENERATED ALWAYS AS IDENTITY,
genre_id INT,
author_id INT,
label_id INT,
publish_date DATE,
archived BOOLEAN,
PRIMARY KEY(id),
FOREIGN KEY (genre_id) REFERENCES genres (id),
FOREIGN KEY (author_id) REFERENCES authors (id),
FOREIGN KEY (label_id) REFERENCES labels (id)
);
CREATE TABLE books (
id INT,
title VARCHAR(100),
publisher VARCHAR(100),
cover_state VARCHAR(100),
FOREIGN KEY(id) REFERENCES item(id)
);
CREATE TABLE music_albums (
id INT,
name VARCHAR(100),
on_spotify BOOLEAN,
FOREIGN KEY(id) REFERENCES item(id)
);
CREATE TABLE games (
id INT,
multiplayer BOOLEAN,
last_played_at DATE,
FOREIGN KEY(id) REFERENCES item(id)
);