[뭐라도 해야지...] MySql 테이블 생성

Momenter·2021년 9월 17일
0

뭐라도 해야지...

목록 보기
3/8

[뭐라도 해야지...] 다이어리 웹 페이지 테이블 생성 MySql

docker를 이용해서 mysql 서버를 구축 해보자

필용한것들

  1. os에 맞는 최신버전의 docker 설치하기
    https://www.docker.com/get-started 링크를 따라들어가 docker를 설치해 줍시다.

  2. git설치하기
    https://git-scm.com 링크를 따라들어가 os에 맞는 최신버전의 git을 설치해주면 됩니다.

  3. git bash로 MySql docker 컨네이너 생성해주기
    https://poiemaweb.com/docker-mysql 저는 이 포스팅을 참고 하여 생정했습니다.

  4. mysql워크벤치 설치후 docker로 생성해준 DB로 접속하여 작업하기

table 생성하기

  1. user table 생성 쿼리
create table `tbl_user` (
uidx bigint auto_increment,
email varchar(300),
`name` varchar(100) not null,
`password` varchar(200) not null,
birthdate date,
regdate timestamp default current_timestamp,
constraint pk_tbl_user primary key(uidx),
constraint uq_tbl_user unique(email)
);
  1. post table 생성 쿼리
create table `tbl_post` (
pidx bigint auto_increment,
pcontent mediumtext not null,
writer varchar(100) not null,
regdate timestamp not null default current_timestamp,
updatedate timestamp,
secret enum('y', 'n') default 'n',
uidx bigint, 
constraint pk_tbl_post primary key(pidx),
constraint fk_tbl_post foreign key(uidx) references tbl_user(uidx) 
);
  1. repply table 생성 쿼리
create table `tbl_reply` (
ridx bigint auto_increment,
rcontent mediumtext not null,
writer varchar(100) not null,
regdate timestamp not null default current_timestamp,
updatedate timestamp,
uidx bigint,
pidx bigint, 
constraint pk_tbl_reply primary key(ridx),
constraint fk_tbl_reply_post foreign key(pidx) references tbl_post(pidx), 
constraint fk_tbl_reply_user foreign key(uidx) references tbl_user(uidx) 
);
  1. schedule table 생성 쿼리
create table `tbl_schedule` (
sidx bigint auto_increment,
scontent text not null,
startdate datetime not null default current_timestamp,
enddate datetime not null,
priority int(4) default 1,
constraint pk_schedule primary key(sidx)
);
  1. attach table 생성 쿼리
create table `tbl_attach` (
uuid varchar(40),
uploadpath varchar(200) not null,
filename varchar(400) not null,
pidx bigint,
constraint pk_attch primary key(uuid),
constraint fk_attach_post foreign key(pidx) references tbl_post(pidx)
);

다음 할 일

스프링 부트 프로젝트 생성 및 mysql 연동하기

profile
순간을 기록하는 개발자

0개의 댓글