CS/Database

[데이터베이스] 3. Data Modeling Using ER Model

공영재 2023. 12. 1. 23:22

Reference - Fundamentals of Database Systems 7th edition

 

 

Database Design Process

 

E-R(Entity-Relationship) Diagram : Conceptual Design의 일종.

ER model은 아래 3개의 main concepts을 가진다.

 

- entity

Entity : Mini-world를 표현하기 위해 추상화된, attribute를 가지고 있는 객체다. Entity들의 집합을 Entity Type이라 하며, entity type의 특정 시점에서의 collection을 Entity Set이라 한다. entity는 ER Diagram에서 네모로 표현한다.

아래에서 서술하는 key attribute를 가지고 있지 않은 entity를 weak entity라 하며, 식별을 위해 다른 entity에 의존한다.

 

- attribute

attribute는 객체를 나타내는 속성으로, simple / composite / multivalued가 있다.

simple attribute는 한 개의 값으로 표현되어진다. (ex. yes or no)

composite attribute는 여러 개의 components로 구성된다. (ex. Name(First, Last))

Multi-valued는 해당 attribute에 여러 값이 올 수 있음을 의미한다. (ex. {color})

attribute는 ER Diagram에서 타원으로 표현한다.

key attribute는 학생 entity에서의 '학번'처럼, entity를 대표하는 특정 attribute를 말한다.

이때 key attribute는 composite일 수 있고, 여러개의 key를 가질 수도 있다. key는 ER diagram에서 underlined로 표시된다.

 

- relationship

entity간의 관계를 나타낸다.

degree는 relationship에 참여하는 entity가 몇개인지를 나타낸다.

relationship type은 relationship의 이름과 entity type, constraints를 식별하는 schema description으로,

ER diagram에서 마름모로 표현된다. relationship type 또한 attribute를 가질 수 있다.

relationship set은 relationship type의 현재 시점에서의 state라고 보면 된다.

relationship type의 constraints는 크게 cardinality ratio와 existence dependency(=participation constraint)로 나눌 수 있다.

Cardinality ratio는 relationship으로 연결되어지는 두 entity가 1:1, N:1, M:N 관계로 나타내어짐을 의미한다.

Existence Ddependency는 두 entity가 부분 참여냐 전체 참여냐를 의미한다.

이 말은, entity가 relationship에 반드시 속해야하면 전체 참여(double line)고, 그렇지 않으면 부분 참여(single line)라고 말한다. 또한 다른 표현법으로 (min, max) notation을 쓰기도 한다.

예로 (0, 1)이면 부분참여, (1, 1)이면 전체 참여, (1,N)이면 N:1 ratio라 할 수 있다.

아래 첨부 이미지를 확인해보면 쉽게 이해할 수 있을 것이다.

ER diagram 표현법

 

Company ER diagram 예시 - (min, max) notation 사용

 

Alternative Notations으로 UML class diagram이 있다.

 

Company UML class diagram 예시

반응형
loading