오뚝이개발자

[DB] CH4. intermediate SQL(중급 SQL) - View, integrity constraints 본문

CS 기초/DB

[DB] CH4. intermediate SQL(중급 SQL) - View, integrity constraints

땅어 2020. 11. 2. 15:15
728x90
300x250

 

View란?

  • 특정 user에게 특정 data를 숨긴 채 보여주는 일종의 virtual relation(새로운 relation을 만드는 것이 X)
  • 사용 이유 : 모든 user에게 전체 데이터를 다 보여주는 것을 원하지 않을 때
    • 예컨대, instructor relation에서 ID, name, dept_name만 보여주고 salary 데이터는 숨겨서 보여주고 싶을 때

view 생성 쿼리 예시

Integrity constraints

DB에 추가되는 변동사항이 data consistency를 잃게 만들지 않도록 하는 제약조건

  • Integrity constraints on a single relation
    • not null
    • primary key
    • unique : 유일성
    • check(P) : 해당 predicate를 만족하는지 조건검사

check를 사용하는 예시

  • Referential integrity constraints
    • foreign key constraints
728x90
300x250
Comments