STUDY/database

관계형 데이터베이스

까미이모 2023. 11. 20. 21:35

Set

  • 서로 다른 elements를 가지는 collection
  • 하나의 set에서 elements의 순서는 중요하지 않다
  • e.g. {1, 3, 11, 4, 7}

Cartesian product: set A의 요소와 setB 의 요소를 잇는 모든 경우의 수

Cartesian product

수학에서 relation 의 의미

  • subset of Cartesian product
  • set of tuples 튜블들의 집합

 

Relational Data Model

domain - set of atomic values 더이상 나눠질수없는 값들의 집합, 각 속성이 가질 수 있는 값의 범위

attribute - domain이 relation에서 맡은 역할 이름

tuple - 각 attribute의 값으로 이루어진 리스트. 일부값은 null일 수 있다.

relation - set of tuples, 테이블로 표현되어 테이블이라고도 한다.

student relation의 구조

Relation Schema

  • relation의 구조를 나타낸다.
  • relation 이름과 attributes 리스트로 표기된다.
  • e.g. STDENT(id, name, grade, major, phone_num, emer_phone_num)
  • attribute와 관련된 constraints도 포함한다.

 

Degree of a Relation(차수)

  • relation schema 에서 attributes의 수
  • e.g. STDENT(id, name, grade, major, phone_num, emer_phone_num) → degree 6

 

Relational Database

  • relational data model에 기반하여 구조화된 데이터베이스
  • 여러개의 relations로 구성된다.

 

Relation의 특징들

  • 중복된 tuple을 가질 수 없다(relation is set of tuples)
  • relation의 tuple을 식별하기 위해 attribute의 부분 집합을 key로 설정한다. ex) 학생예시에서의 id
  • relation에서 tuple의 순서는 중요하지 않다.
  • 하나의 relation에서 attribute의 이름은 중복되면 안된다.
  • 하나의 tuple에서 attribute의 순서는 중요하지 않다.
  • attribute는 atomic 해야한다. composite or multivalued attribute 허용안됨(atomic: 원자적인, 더이상 나눠질수없는)

composite or multivalued attribute 의 예시

NULL의 의미

  • 값이 존재하지 않는다.
  • 값이 존재하나 아직 그 값이 무엇인지 알지 못한다.
  • 해당 사항과 관련이 없다.

 

참고: https://youtu.be/gjcbqZjlXjM?si=p3mjUX2oRN3naj4R

'STUDY > database' 카테고리의 다른 글

DB구축 예시  (1) 2023.11.21
SQL의 개념  (2) 2023.11.21
키(key)의 종류, constraints 종류  (0) 2023.11.20
database schema 정리  (0) 2023.11.14
데이터베이스 기본개념  (1) 2023.11.14