[UMC-Spring Server] Chapter 3. 데이터베이스

Elmo·2023년 7월 4일
0

UMC-Spring Server

목록 보기
3/3
post-thumbnail

🔥미션

1. AWS RDS 구축

데이터베이스 생성







2. RDS 인코딩 및 타임존 구축

RDS 설정
파라미터 그룹 -> 파라미터 그룹 생성 -> 아까 위에서 적은 VPC이름

파리미터 편집
1. time_zone

2. char



3. collation


4. lower_case_table_names



MySQL을 사용할 경우 얘는 변경하면 안되는 거 같다..0으로 다시 설정

DB 재부팅을 하면 된다.
RDS 보안 그룹에 내 IP 등록

EC2 인스턴스에서 사용한 보안 그룹 ID 복사하고
RDS 보안그룹 인바운드 규칙 편집

3. 당근마켓 분석해서 DB 설계하기.

ERD 설계해서 mysql로 추출하면 DB를 생성하는 코드로 변환가능하다.


create table userInfo(
userId int primary key,
userName varchar(20) NOT NULL,
nickname varchar(20) NOT NULL,
email varchar(200) NOT NULL,
phone varchar(20) NOT NULL,
imgUrl varchar(200) NULL,
temperature int NOT NULL
);

create table Town (
townId int primary key,
townName varchar(20) NOT NULL,
city varchar(20) NOT NULL
);

create table Category (
categoryId int primary key NOT NULL,
categoryName varchar(20) NULL
);

create table Post (
postId int primary key,
title varchar(200) NOT NULL,
price int NOT NULL,
content varchar(200) NOT NULL,
userId int NOT NULL,
categoryId int NOT NULL,
townId int NOT NULL,
foreign key (userId) references userInfo(userId),
foreign key (townId) references Town(townId),
foreign key (categoryId) references Category(categoryId)
);

create table chatRoom (
roomId int primary key NOT NULL,
postId int NOT NULL,
sellerId int NOT NULL,
buyerId int NOT NULL,
foreign key (sellerId) references userInfo(userId),
foreign key (buyerId) references userInfo(userId),
foreign key (postId) references Post(postId)
);

create table Chat (
chatId int primary key,
message varchar(200) NOT NULL,
roomId int NOT NULL,
foreign key (roomId) references chatRoom(roomId)
);

create table Address (
addressId int primary key,
userId int NOT NULL,
townId int NOT NULL,
foreign key (userId) references userInfo(userId),
foreign key (townId) references Town(townId)
);

create table Area (
areaId int primary key,
area varchar(20) NOT NULL,
addressId int NOT NULL,
userId int NOT NULL,
foreign key (userId) references userInfo(userId),
foreign key (addressId) references Address(addressId)
);

profile
엘모는 즐거워

0개의 댓글

관련 채용 정보