윤준석

ADD: database initialization sql file

1 +CREATE DATABASE secondhand-noti-bot;
2 +
3 +CREATE TABLE user
4 +(
5 + id INT(10) NULL AUTO_INCREMENT
6 +);
7 +
8 +CREATE TABLE keyword
9 +(
10 + id INT NOT NULL,
11 + keyword VARCHAR NULL
12 +);
13 +
14 +CREATE TABLE user_keyword
15 +(
16 + id INT NOT NULL AUTO_INCREMENT,
17 + user_id INT NOT NULL,
18 + keyword_id INT NOT NULL,
19 + FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE,
20 + FOREIGN KEY (keyword_id) REFERENCES keyword (id) ON DELETE CASCADE,
21 +);
22 +
23 +CREATE TABLE item
24 +(
25 + id INT NOT NULL,
26 + keyword_id INT NOT NULL,
27 + platform VARCHAR NOT NULL,
28 + name VARCHAR NOT NULL,
29 + price INT NOT NULL,
30 + thumbnail_url VARCHAR NULL,
31 + item_url VARCHAR NOT NULL,
32 + extra_info TEXT NULL,
33 + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
34 +);
35 +
36 +CREATE TABLE item_check
37 +(
38 + id INT NOT NULL AUTO_INCREMENT,
39 + item_id INT NULL,
40 + user_id INT NULL,
41 + FOREIGN KEY (item_id) REFERENCES item (id) ON DELETE CASCADE,
42 + FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE
43 +);