ER図(データベース設計)を元にDBを作成しましょう。

■動画内参考画面図

https://app.moqups.com/CuMREa9hHw/view/page/abe28f1ad

■参考ER図

https://cacoo.com/diagrams/t6zG98smP6hDIS0c/7C05A

動画ないで利用したSQLコマンドはこちら↓

テンプレート

CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
created DATETIME,
modified DATETIME
);

CREATE TABLE articles (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
created DATETIME,
modified DATETIME,
FOREIGN KEY user_key (user_id) REFERENCES users(id)
) CHARSET=utf8mb4;

実際に動画内で利用したコマンド

USE original;

CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
created DATETIME,
modified DATETIME
);

CREATE TABLE shops (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
prefecture VARCHAR(255),
tel VARCHAR(255),
simple_comment VARCHAR(255),
detail_comment TEXT,
image_file VARCHAR(255),
created DATETIME,
modified DATETIME,
FOREIGN KEY user_key (user_id) REFERENCES users(id)
) CHARSET=utf8mb4;

CREATE TABLE comments (
id INT AUTO_INCREMENT PRIMARY KEY,
shop_id INT NOT NULL,
title VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
comment TEXT,
rate INT,
created DATETIME,
modified DATETIME,
FOREIGN KEY shop_key (shop_id) REFERENCES shops(id)
) CHARSET=utf8mb4;