관계형 데이터베이스(relational database)개념과 relation, primary key(기본키), foreign key(외래키), constraints를 알아보자

황인성·2023년 3월 18일
0


set : 서로 다른 elements를 가지는 coolection
relational의 수학적 의미
set A와 B가 있다고 가정했을 때 이 둘이 가질 수 있는 경우의 수 조합은 A X B로 표기할 수 있는데 이를 Cartesian product라고 한다

tuple : 몇 개의 엘리먼트들로 이루어진 리스트 n개의 집합으로 이루어진 튜플은 n-tuple

relational data model에서는 set 이 도메인을 의미한다. 이 도메인은 엘리먼트 혹은 벨류라고 하는데 이런 값들의 집합을 엘리먼트라고 한다.

domain : set of atomic values
domain name : domain 이름
attribute : domain이 relation에서 맡은 역할 이름
tuple : 각 attribute의 값으로 이루어진 리스트, 일부값은 null일수 있다
relation : set of tuple
relation name : relation

relation schema : relation 의 구조를 나타낸다
relation 이름과 attributes리스트로 표기된다.
attributes와 관련된 constraints()도 포함한다.

degree of a relaiton : relation schema에서 attributes의 수
relation (or relation state) :relation이 추상적인, 개념적인 의미인지 아니면 tuple들의 집합으로써의 의미인지 잘 파악할 필요가 있다.

relational database : relation data model에 기반하여 구조화된 database
relational database는 여러 개의 relations로 구성된다.

relational database schema : relational database가 여러 개의 relation으로 구성될 때, relation schemas의 집합 + integrity constraints set

relation의 특징 :
relation은 중복된 tuple을 가질 수 없다.
relation의 tuple을 식별하기 위해 attribute의 부분 집합을 key로 식별한다.
relation에서 tuple의 순서는 중요치 않다.(tuple들을 표시할 때 여러 가지 방법이 있을 수 있다.)
하나의 relation에서 attribute의 이름은 중복되면 안된다.
하나의 tuple에서 attribute의 순서는 중요하지 않다.(순서를 바꿔도 의미가 달라지진 않는다.)
attribute는 atomic 해야한다.(atomic한 : 원자적인, 더이상 나누어질 수 없는)
composite나 multivalued attribute는 허용되지 않는다.

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

keys : relation에서 tuples를 unique하게 식별할 수 있는 attributes set

superkey : relation에서 tuples를 unique하게 식별할수 있는 attribute set

primary key : tuples을 unique하게 식별하기 위해 선택된 candidate key

unique key : primary key가 아닌 candidate key ,alternate key

foreign key : 다른 relation의 PK를 참조하는 attributes set

constraints : relational database의 relation 들이 지켜야 하는 제약 사항

inplicit constraints : relational data model 자체가 가지는 constraints, 중복 튜블 안됨, 같은 이름의 속성 가질 수 없음.
schema-based constraints : 주로 DDL을 통해 스키마에 직접 명시할 수 있는 constraints. (explicit constraints)

profile
문제 해결을 위해 끊임없이 파고드는 걸 좋아합니다.

0개의 댓글