데이터베이스의 키

SQL을 활용한 탐색적 데이터 분석

Christina Maimone

Data Scientist

외래 키

Foreign key example linking films to actors

SQL을 활용한 탐색적 데이터 분석

외래 키

  • 다른 행을 참조

    • 다른 테이블 또는 같은 테이블
    • 고유 ID로 참조

                 >> 고유하고 NULL이 아닌 값을 포함하는 기본 키 열
      
  • 참조된 열 OR NULL 값으로 제한된 값

SQL을 활용한 탐색적 데이터 분석

Entity relationship diagram

SQL을 활용한 탐색적 데이터 분석

Entity relationship diagram showing link between tag_company and company tables

SQL을 활용한 탐색적 데이터 분석

Entity relationship diagram showing self-reference in company table

SQL을 활용한 탐색적 데이터 분석

Entity relationship diagram

SQL을 활용한 탐색적 데이터 분석

Entity relationship diagram with primary keys

SQL을 활용한 탐색적 데이터 분석

Coalesce 함수

coalesce(value_1, value_2 [, ...])
  • 행 단위로 작동
  • NULL이 아닌 첫 번째 값 반환
SQL을 활용한 탐색적 데이터 분석

Coalesce 함수

SELECT *
  FROM prices;
 column_1 | column_2 
----------+----------
          |       10
          |         
       22 |         
        3 |        4
SELECT coalesce(column_1, column_2)
  FROM prices;
 coalesce 
----------
       10

       22
        3
SQL을 활용한 탐색적 데이터 분석

계속 탐색해 볼까요!

SQL을 활용한 탐색적 데이터 분석

Preparing Video For Download...