create database blog;
use blog;
create table user(
user_id int auto_increment,
email varchar(50) unique not null,
password varchar(50) not null,
name varchar(50) not null,
created_at timestamp default current_timestamp,
primary key (user_id)
);
create table post(
post_id int auto_increment,
user_id int,
title varchar(50) not null,
story text,
created_at timestamp default current_timestamp,
primary key(post_id),
FOREIGN KEY post_user (user_id) REFERENCES user(user_id)
);
create table comment(
user_id int,
post_id int,
commemt_id int primary key auto_increment,
story varchar(1000),
created_at timestamp default current_timestamp,
FOREIGN KEY comment_user (user_id) REFERENCES user(user_id),
FOREIGN KEY commemt_post (post_id) REFERENCES post(post_id)
);
create table post_detail(
post_class varchar(50) not null,
post_id int,
FOREIGN KEY post_detail (post_id) REFERENCES post(post_id)
);
create table user_detail(
user_class varchar(50) not null,
user_id int,
FOREIGN KEY user_detail (user_id) REFERENCES user(user_id)
);
create table user_post_like(
user_id int,
post_id int,
primary key(user_id, post_id),
FOREIGN KEY like_user (user_id) REFERENCES user(user_id),
FOREIGN KEY like_post (post_id) REFERENCES post(post_id)
);