create database db_codingrecipe;
create user user_codingrecipe@localhost identified by '1234';
grant all privileges on db_codingrecipe.* to user_codingrecipe@localhost;
drop table if exists board_table;
create table board_table(
id bigint primary key auto_increment,
boardWriter varchar(50),
boardPass varchar(20),
boardTitle varchar(50),
boardContents varchar(500),
boardCreatedTime datetime default now(),
boardHits int default 0,
fileAttached int default 0
);
drop table if exists board_file_table;
create table board_file_table
(
id bigint auto_increment primary key,
originalFileName varchar(100),
storedFileName varchar(100),
boardId bigint,
constraint fk_board_file foreign key(boardId) references board_table(id) on delete cascade
);
drop table if exists comment_table;
create table comment_table(
id bigint primary key auto_increment,
commentWriter varchar(50),
commentContents varchar(200),
boardId bigint,
commentCreatedTime datetime default now(),
constraint fk_comment_table foreign key (boardId) references board_table(id) on delete cascade
);