Reduction to Relation Schemas: 두 판 사이의 차이
| (같은 사용자의 중간 판 4개는 보이지 않습니다) | |||
| 9번째 줄: | 9번째 줄: | ||
E가 단순한 descriptive attribute(a<sub>1</sub>, ..., a<sub>n</sub>)만을 가진 strong entity set이라고 하면, 해당 entity를 E라는 이름의 schema로 표현할 수 있다. 이는 다음과 같이 표현된다.<ref>이때 모든 attribute는 simple하다.</ref> | E가 단순한 descriptive attribute(a<sub>1</sub>, ..., a<sub>n</sub>)만을 가진 strong entity set이라고 하면, 해당 entity를 E라는 이름의 schema로 표현할 수 있다. 이는 다음과 같이 표현된다.<ref>이때 모든 attribute는 simple하다.</ref> | ||
student (<ins>ID</ins>, name, phone_number) | student(<ins>ID</ins>, name, phone_number) | ||
또한 해당 schema 내에는 n개의 서로 다른 attribute가 존재한다.또한 schema에 존재하는 각 tuple 들은 entity set E 안의 하나의 entity에 해당한다. 또한 해당 entity set의 primary key가 relation schema에서도 primary key로 사용된다. | 또한 해당 schema 내에는 n개의 서로 다른 attribute가 존재한다.또한 schema에 존재하는 각 tuple 들은 entity set E 안의 하나의 entity에 해당한다. 또한 해당 entity set의 primary key가 relation schema에서도 primary key로 사용된다. | ||
| 17번째 줄: | 17번째 줄: | ||
Composite attribute set: composite attribute의 하위 구성 요소들을 분해하여 각각의 attribute들로 변환한다. 예를 들어 name이 first_name, middle_initial, last_name이라는 세개의 하위 attribute로 이루어 진다면, studnet는 다음과 같이 나타내어 질 수 있다. | Composite attribute set: composite attribute의 하위 구성 요소들을 분해하여 각각의 attribute들로 변환한다. 예를 들어 name이 first_name, middle_initial, last_name이라는 세개의 하위 attribute로 이루어 진다면, studnet는 다음과 같이 나타내어 질 수 있다. | ||
student (<ins>ID</ins>, first_name, middle_initial, last_name, phone_number) | student(<ins>ID</ins>, 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는 다음 특징을 가진다. | Multivalued attribute는 다른 attribute와는 다르게 취급된다. 다른 attribute들이 직접적으로 해당 schema의 attribute로 mapping되는 것과는 다르게, multivalued attribute는 해당 attribute를 표현할 새로운 relation schema를 만들어야 한다. 이때 Entity E의 multivalued attribute M을 나타내는 schema EM는 다음 특징을 가진다. | ||
| 23번째 줄: | 23번째 줄: | ||
예를 들어 phone_number는 한 사람이 여러 전화 번호를 가질 수 있기 때문에 multivalued attribute에 해당된다. 따라서, 이를 표현하기 위해 다음과 같은 schema를 만들 수 있으며, student schema 또한 아래와 같이 변경된다. | 예를 들어 phone_number는 한 사람이 여러 전화 번호를 가질 수 있기 때문에 multivalued attribute에 해당된다. 따라서, 이를 표현하기 위해 다음과 같은 schema를 만들 수 있으며, student schema 또한 아래와 같이 변경된다. | ||
stud_phone_num (<ins>ID</ins>, <ins>phone_number</ins>) | stud_phone_num(<ins>ID</ins>, <ins>phone_number</ins>) | ||
student (<ins>ID</ins>, first_name, middle_initial, last_name) | student(<ins>ID</ins>, first_name, middle_initial, last_name) | ||
또한 derived attribute는 아예 schema에서 삭제된다. | 또한 derived attribute는 아예 schema에서 삭제된다. | ||
| 32번째 줄: | 32번째 줄: | ||
==Representation of Relationship Sets== | ==Representation of Relationship Sets== | ||
R을 relationship set이라고 하자. 이때 relation R에 참여하는 각각의 entity set들의 primary key의 | R을 relationship set이라고 하자. 이때 relation R에 참여하는 각각의 entity set들의 primary key의 합집합으로 구성된 attribute set[https://junhoahn.kr/junyoung/index.php/Entity_Relationship_Model#Relational_Set]을 a<sub>1</sub>, ..., a<sub>m</sub>이라고 하고, | ||
relationship set R이 가지는 descriptive attributes를 b<sub>1</sub>, ..., b<sub>n</sub>이라고 하자. 이때, R에 대한 relation schema에 포함되는 attribute는 다음과 같이 표현된다. | relationship set R이 가지는 descriptive attributes를 b<sub>1</sub>, ..., b<sub>n</sub>이라고 하자. 이때, R에 대한 relation schema에 포함되는 attribute는 다음과 같이 표현된다. | ||
| 39번째 줄: | 39번째 줄: | ||
이때, 해당 schema의 primary key는 원래의 relationship set의 primary key이 사용된다. | 이때, 해당 schema의 primary key는 원래의 relationship set의 primary key이 사용된다. | ||
==Redundancy of Schemas== | |||
A가 attribute(a<sub>1</sub>, ..., a<sub>n</sub>)를 가지는 weak entity set이고, B는 A에 대한 identifying set이라고 하자. 이때 A와 B 사이의 identifying relation은 특별하게 처리된다. identifying relation은 descriptive attribute를 가지고 있지 않으므로, 만약 해당 relation에 대한 schema가 존재한다면 weak entity set의 primary key로 구성된다. 이는 weak entity set의 schema와 중복이다. 따라서 identifying relation의 schema는 굳이 만들지 않는다. | |||
[[파일:RedundancyOfSchemaExample.png|테두리|프레임없음|500x500픽셀]] | |||
위에서의 이미지에서도 section schema는 sec_course schema에서 나타나는 attribute들을 모두 포함한다. | |||
===Many-to-one(one-to-many)에서의 Redundancy=== | |||
entity set A, B 사이에 many-to-one(혹은 one-to-many) relation이 존재하고 A가 relation에 total participating을 한다고 가정하자. 이 경우 relationship set을 표현하는 것 대신, A의<ref>"many" 측의</ref> attribute set에 B의<ref>"one" 측의</ref> primary key에 해당하는 attribute를 추가함으로써 redundancy를 피할 수 있다. | |||
아래 그림에서, instructor와 student의 schema는 다음과 같이 표현되어 redundancy를 피할 수 있다. | |||
[[파일:ManyToOneRedundancy.jpg|테두리|프레임없음|500x500픽셀]] | |||
instructor(ID, name, salary, dept_name) | |||
student(ID, name, tot_cred, dept_name) | |||
===One-to-one에서의 Redundancy=== | |||
entity set A, B 사이에 one-to-one relation이 존재하면, 어느 쪽을 "many" 측으로 삼던 상관없다. 이 말은 A와 B가 one-to-one relation을 이룰 때, A에 B의 primary key를 더하던, B에 A의 primary key를 더하던 상관없다는 뜻이다. 다만, "many"로 고른 측이 해당 relation에 partial participating을 한다면, "many" 측의 schema에서의 추가 속성의 값에는 null 값이 생길 수 있다. | |||
==각주== | ==각주== | ||
[[분류:데이터베이스 시스템]] | [[분류:데이터베이스 시스템]] | ||
2025년 4월 20일 (일) 05:16 기준 최신판
상위 문서: 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의 합집합으로 구성된 attribute set[1]을 a1, ..., am이라고 하고, relationship set R이 가지는 descriptive attributes를 b1, ..., bn이라고 하자. 이때, R에 대한 relation schema에 포함되는 attribute는 다음과 같이 표현된다.
이때, 해당 schema의 primary key는 원래의 relationship set의 primary key이 사용된다.
Redundancy of Schemas
A가 attribute(a1, ..., an)를 가지는 weak entity set이고, B는 A에 대한 identifying set이라고 하자. 이때 A와 B 사이의 identifying relation은 특별하게 처리된다. identifying relation은 descriptive attribute를 가지고 있지 않으므로, 만약 해당 relation에 대한 schema가 존재한다면 weak entity set의 primary key로 구성된다. 이는 weak entity set의 schema와 중복이다. 따라서 identifying relation의 schema는 굳이 만들지 않는다.
위에서의 이미지에서도 section schema는 sec_course schema에서 나타나는 attribute들을 모두 포함한다.
Many-to-one(one-to-many)에서의 Redundancy
entity set A, B 사이에 many-to-one(혹은 one-to-many) relation이 존재하고 A가 relation에 total participating을 한다고 가정하자. 이 경우 relationship set을 표현하는 것 대신, A의[2] attribute set에 B의[3] primary key에 해당하는 attribute를 추가함으로써 redundancy를 피할 수 있다.
아래 그림에서, instructor와 student의 schema는 다음과 같이 표현되어 redundancy를 피할 수 있다.
instructor(ID, name, salary, dept_name) student(ID, name, tot_cred, dept_name)
One-to-one에서의 Redundancy
entity set A, B 사이에 one-to-one relation이 존재하면, 어느 쪽을 "many" 측으로 삼던 상관없다. 이 말은 A와 B가 one-to-one relation을 이룰 때, A에 B의 primary key를 더하던, B에 A의 primary key를 더하던 상관없다는 뜻이다. 다만, "many"로 고른 측이 해당 relation에 partial participating을 한다면, "many" 측의 schema에서의 추가 속성의 값에는 null 값이 생길 수 있다.