E-R Diagram

grilledbacon09·2024년 4월 14일

Database

목록 보기
4/12

Modeling

DB는 다음과 같이 model될 수 있음
entity들의 collection
entity 간의 ralationship

Entity
말 그대로 무언가 존재하는 것
예시) 특정한 학생: 홍길동

entity는 attribute를 가짐
entity set은 동일한 특성을 가진 entity들을 묶어놓은 것

Relationship
말 그대로 entity set간의 관계를 나타냄

E-R diagram

Emtity - relation diagram


사각형이 entity set
마름모가 relationship set
entity set 내부에 attribute list를 표시
밑줄쳐진 attribute는 primary key를 표시

relationship set도 attribute를 가질 수 있음

relationship set의 attribute는 점선으로 연결

Degree of relationship set

relationship이 2개의 entity set을 포함할 때, binaryrelationship\color{red}{binary\enspace relationship}이라고 함
(relationship의 degree가 2다 라고도 함)
degree가 3 이상인 relationship은 잘 사용하지 않음 -> 알아보기 힘들기 때문에
degree가 3 이상인 relationship을 ternary relationship이라고도 함

Attribute

entity는 여러 attribute를 가진다.

domain - 각 attribute가 가질수 있는 value의 집합

attribute type
simple <-> composite attribute (더 분해할 수 있는 attribute인지 아닌지 예시) 주소 -> 시, 군/구, 동으로 분해 가능)
single <-> multivalued attribute (value가 여러개일 수 있는지 예시) 전화번호)
derived attribute (다른 attribute로 계산될 수 있는 attribute)

Mapping cardinality constraint

binary relationship에서 각 entity set이 어떤 방식으로 연결되어있는지

Key

Key(한개 이상의 attribute)는 한 entity를 구분하는 identifier
super key: 각 entity를 구분할 수 있게 하는 key의 set(unique하다는 소리)
candidate key: minimal한 super key
primary key: candidate key중 하나를 골라 primary key로 사용

Role

entity가 relationship에서 무슨 역할을 하는지 표시

이렇게 line 위에 적어서 표시

Cardinality constraint

화살표(->) 는 one을 의미
실선( - ) 은 many를 의미

혹은 실선 위에 숫자를 적어서 범위를 직접 표시 min..max 꼴
ex) 0..* (0 부터 \infin까지 가능하다는 뜻)

Total participation

entity set의 모든 entity가 relationship set에 포함됨을 의미함
relationship set과 entity set을 두 줄로 연결하여 표시함

Ternary relationship

3개 이상의 entity set이 연결된 relationship
one ( -> ) 연결은 하나만 있어야 함 why? <- 두 개 이상 사용하면 여러 의미로 해석 될 수 있음

Weak entity set

primary key가 없는 entity set
다른 entity set에 의존하여 primary key를 만듦
그 다른 entity set을 identifying entity set이라 함
그 둘이 참여한 relationship을 identifying relationship이라고 하고 두 줄 마름모로 표시함 (위 그림 참고)
weak entity set의 attribute를 discriminator 혹은 partial key라고 함

0개의 댓글