-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateTables.sql
More file actions
104 lines (82 loc) · 1.9 KB
/
createTables.sql
File metadata and controls
104 lines (82 loc) · 1.9 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
CREATE DATABASE "FreeLibraryDB"
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'Russian_Russia.1251'
LC_CTYPE = 'Russian_Russia.1251'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;
CREATE TABLE libUser (
id BIGSERIAL PRIMARY KEY,
login text NOT NULL,
firstName text,
lastName text,
passwordHash text,
uRole text
);
INSERT INTO libUser (login, firstname, lastName, passwordHash, uRole) VALUES
('mainAdmin', 'Таисия', 'Дорошенкова', '$2a$10$qcjvvglHZa3ASDdPKBYd4ODz1HEKT3k7iev.pBLG.WsHMz1kzXWRS', 'admin');
SELECT * FROM libUser;
CREATE TABLE author (
id BIGSERIAL PRIMARY KEY,
firstName text,
secondName text,
lastName text,
century int
);
INSERT INTO author (firstname, secondName, lastName, century) VALUES
('Фёдор', 'Михайлович', 'Достоевский', 19);
SELECT * FROM author;
CREATE TABLE genre (
name text PRIMARY KEY
);
INSERT INTO genre (name) VALUES
('classic'),
('adventures'),
('detective'),
('fantasy');
INSERT INTO genre (name) VALUES
('poetry'),
('religion'),
('philosophy'),
('science'),
('computers'),
('sport'),
('cookery'),
('other');
DELETE FROM genre;
SELECT * FROM genre;
CREATE TABLE category (
name text PRIMARY KEY
);
INSERT INTO category (name) VALUES
('adults'),
('teenagers'),
('children');
DELETE FROM category;
SELECT * FROM category;
CREATE TABLE book (
id BIGSERIAL PRIMARY KEY,
name text,
authorID int REFERENCES author(id),
genreID text REFERENCES genre(name),
categoryID text REFERENCES category(name),
popularity int,
description text
);
SELECT * FROM book;
CREATE TABLE notification (
id BIGSERIAL PRIMARY KEY,
user int REFERENCES libUser(id),
notice text,
notifDate date
);
SELECT * FROM notification;
CREATE TABLE uncheckedBook (
id BIGSERIAL PRIMARY KEY,
user int REFERENCES libUser(id),
bookname text,
author text,
description text
);
SELECT * FROM uncheckedBook;