DB - Lecture4

Pyro·2021년 9월 8일
0

Database

목록 보기
4/8

DB 4일차 (Relational Data Integrity)

복습

Cartesian Product 와 Join 의 차이: Selection 조건의 여부

오늘 학습 내용 요약

  • Outer Join
  • Integrity
  • NULL : missing or unknown value

Outer Join

  • LEFT OUTER JOIN
  • RIGHT OUTER JOIN
  • FULL OUTER JOIN

Outer Join 은 Natural Join, Set Operation, Cartesian Product 3가지를 조합해서 Derive 할 수 있다.
귀찮아서 Derive 하는 과정은 설명을 생략한다.

Components in Relation Model

  • Data Structure (Relations)
  • Data Manipulation (Operations)
  • Data Integrity (Rules)

Attribute vs Domain

  • Attribute: 이름 붙은 Column, 혹은 인덱스 붙여진 이름
  • Domain: 어떤 값이 해당 Column 에 들어갈 수 있는가. 인덱스가 실제로 연결하는 객체 혹은 Value
    • 예시) Age attribute 에 할당될 domain 은 0과 200 사이의 숫자여야한다.

기습 질문: Model vs Domain vs Entity ?

Integrity

Keys

key := set of attributes

  • Candidate Keys
  • Primary Keys
  • Foreign Keys

Candidate Key

  • Uniqueness: tuple 하나를 identify 할 수 있어야 한다.
  • Minimality: no subset has uniquenss property

Uniqueness 만 만족하면, Super Key 라고 부른다.

Primary Key

  • Candidate Key 에서 아무거나 하나 고른것
  • Entity Integrity: NULL is not allowed

Foreign Key

  • 다른 Relation 의 tuple 을 식별하는 key
  • NULL 이 허용됨
  • Referential Integrity: tuple 을 reference 해야한다.
    • MySQL 공식문서 에 따르면, Uniqueness 와 Null 체크는 하지 않는다고 한다.
    • does not enforce a requirement that the referenced columns be UNIQUE or be declared NOT NULL

Referential Integrity Constraint

  • Referential Integrity 를 만족할 수 있도록, DBMS 차원에서 제약조건을 걸어버린다.
  • Referential Integrity 를 위반하는 DDL 을 실행해야하면, 오류를 내뿜고 실행하지 않는다.
profile
dreams of chronic and sustained passion

0개의 댓글