Reduction to Relation Schemas

youngwiki

상위 문서: Entity Relationship Model

개요

E-R model과 Relation model은 유사한 설계 원칙을 사용하고 있어 E-R design을 relation design으로 변환할 수 있다. 이는 각각의 entity set과 relation set마다 해당하는 relation schema가 존재하기 때문이다. 즉, E-R diagram을 대응되는 relation schema의 집합으로 표현할 수 있는 것이다.

Representing Entity set

Representing Strong entity set

E가 단순한 descriptive attribute(a1, ..., an)만을 가진 strong entity set이라고 하면, 해당 entity를 E라는 이름의 schema로 표현할 수 있다. 이는 다음과 같이 표현된다.[1]

student (ID, name, phone_number)

또한 해당 schema 내에는 n개의 서로 다른 attribute가 존재한다.또한 schema에 존재하는 각 tuple 들은 entity set E 안의 하나의 entity에 해당한다. 또한 해당 entity set의 primary key가 relation schema에서도 primary key로 사용된다.

Representing Strong entity set with Composite Attribute

먼저, strong entity set이 composite attribute set을 가질 경우, relation schema은 다음과 같이 된다. Composite attribute set: composite attribute의 하위 구성 요소들을 분해하여 각각의 attribute들로 변환한다. 예를 들어 name이 first_name, middle_initial, last_name이라는 세개의 하위 attribute로 이루어 진다면, studnet는 다음과 같이 나타내어 질 수 있다.

student (ID, first_name, middle_initial, last_name, phone_number)

Multivalued attribute는 다른 attribute와는 다르게 취급된다. 다른 attribute들이 직접적으로 해당 schema의 attribute로 mapping되는 것과는 다르게, multivalued attribute는 해당 attribute를 표현할 새로운 relation schema를 만들어야 한다. 이때 Entity E의 multivalued attribute M을 나타내는 schema EM는 다음 특징을 가진다.

  • Schema EM은 E의 primary key에 대응되는 attribute와, attribute M에 대응되는 attribute를 통해 primary key를 구성한다.

예를 들어 phone_number는 한 사람이 여러 전화 번호를 가질 수 있기 때문에 multivalued attribute에 해당된다. 따라서, 이를 표현하기 위해 다음과 같은 schema를 만들 수 있으며, student schema 또한 아래와 같이 변경된다.

stud_phone_num (ID, phone_number)
student (ID, first_name, middle_initial, last_name)

또한 derived attribute는 아예 schema에서 삭제된다.

Representation of Weak Entity Sets

A가 attribute(a1, ..., an)를 가지는 weak entity set이고, B는 A에 대한 identifying set이라고 하자. 또한 B는 b1, ..., bn와 같은 attribute 들을 가진다고 하자.

Representation of Relationship Sets

R을 relationship set이라고 하자. 이때 relation R에 참여하는 각각의 entity set들의 primary key의 union으로 구성된 attribute set을 a1, ..., am이라고 하고, relationship set R이 가지는 descriptive attributes를 b1, ..., bn이라고 하자. 이때, R에 대한 relation schemp는 다음과 같이 표현된다.

{a1,...,am}{b1,...,bn}

이때, 해당 schema의 primary key는 원래의 relationship set의 primary key이 사용된다.

각주

  1. 이때 모든 attribute는 simple하다.