본문 바로가기

DataBase/MySQL

관계형데이터베이스의 필요성

 

관계형데이터베이스의 필요성

- 데이터의 중복제거 효율적인 데이터관리

 

목표

- 데이터를 별도의 table로 보관함으로써 중복을 발생시키지 않으면서도 실제로 데이터를 볼때는 

  하나의 table로 합쳐진 결과를 보고 싶다 이를 가능하게 하는것이 MySQL이다

 

*테이블이름 바꾸기 RENAME TABLE topic TO topic_backup;

1.테이블 분리하기

 

2. JOIN 

각각의 독립적인 분리된 테이블을 읽을때 마치 그 테이블들이 하나의 테이블로 저장되어 있던 것

처럼 불러오는 방법

먼저 결합고리를 찾자 topic table의 author_id값과 author table의 id값을 결합하자

SELECT * FROM topic LEFT JOIN author ON topic.author_id = author.id;

 

3.필요없는 행을 지움

SELECT topic.id, title, description, created, name, profile FROM topic LEFT JOIN author ON topic.author_id = author.id;

4. id값 update

 

SELECT topic.id AS topic_id, title, description, created, name, profile FROM topic LEFT JOIN author ON topic.author_id = author.id;

 

'DataBase > MySQL' 카테고리의 다른 글

Internet & database  (0) 2020.08.27
MySQL-read,update  (0) 2020.08.24
MySQL-create row  (0) 2020.08.24
MySQL- table 만들기  (0) 2020.08.23
MySQL- 정의  (0) 2020.08.22