create_db.sql
1.04 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
CREATE DATABASE mamuri_db;
CREATE TABLE user
(
id INT(10) NULL AUTO_INCREMENT
);
CREATE TABLE keyword
(
id INT NOT NULL,
keyword VARCHAR NULL
);
CREATE TABLE user_keyword
(
id INT NOT NULL AUTO_INCREMENT,
user_id INT NOT NULL,
keyword_id INT NOT NULL,
FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE,
FOREIGN KEY (keyword_id) REFERENCES keyword (id) ON DELETE CASCADE,
);
CREATE TABLE item
(
id INT NOT NULL,
keyword_id INT NOT NULL,
platform VARCHAR NOT NULL,
name VARCHAR NOT NULL,
price INT NOT NULL,
thumbnail_url VARCHAR NULL,
item_url VARCHAR NOT NULL,
extra_info TEXT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE item_check
(
id INT NOT NULL AUTO_INCREMENT,
item_id INT NULL,
user_id INT NULL,
FOREIGN KEY (item_id) REFERENCES item (id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE
);