- E-R Diagram
- Attributes
- Mapping Cardinalities in Relationships
- Weak Entity Sets
- Extended E-R Feature
- UML and Other E-R Notations
- Reduction to Relation Schemas
- Design Issues
by Prof. Chang Hwan Lee
--------------------------------------------------------------------------
1. E-R Diagram
- 데이터베이스 Design Tool인 E-R 모델은, Logical Schema인 Table(relational model)로 자동 변환된다
- Entity는 다른 객체와 구별되는 객체고, 이들의 집합은 Entity set이다
- Relationship은 Entity 사이의 관계고, 이들의 수학적 관계 집합은 Relationship set이다
- {(e1, e2, … en) | e1 ∈ E1, e2 ∈ E2, …, en ∈ En}
- binary가 대부분이지만, ternary 이상의 Relationship도 있다. ex) 학생 - 강사 - 프로젝트
- Entity set의 각각은 Relationship에서 “Role”를 가진다 (1개일 필요 없다)
Attributes
- Attributes types
- Simple/Composite attributes: Component attributes의 여부
- Single-valued/Multivalued attributes
- Derived attributes: 다른 attributes로 계산되는 attributes
- Domain: 각 attribute에 허용된 값들의 집합
Mapping Cardinalities in Relationships
- Binary Relationship일 때 다음 types 중 하나를 따른다
- One to one
- One to many
- Many to one
- Many to many
- Participation
- Total participation: 모든 Entity가 Relation에 속한다. (minimum Cardinality는 1이다)
- Partial participation: 몇 entity는 관련 X (minimum Cardinality가 0이다)
- Cardinality
- Ternary Relationship에서는 혼란을 피하기 위해 두 개 이상의 화살표를 피하도록 한다
Weak Entity Sets
- Key
- 각 entity 유일하게 결정하는 Super key / minimal한 Super key에서 Primary key-Alternate key를 결정한다
- Weak Entity Set는 Primary key가 없는 entity set을 말한다
- Weak Entity Set의 Primary Key는 Strong Entity Set에 의해 형성된다 (stored not explicitly but implicit)
- Weak Entity는 Strong Entity 없이 있을 수 없다
- Identifying Entity Set ([Fig 4]와 같은 double diamond) 에 의존한다
- Weak Entity Set의 Discriminator(or Partial key)인 속성들은 [Fig 4]와 같이 점선 밑줄로 표시된다 -> Primary key
E-R 모델 예시
Extended E-R Features
- Specialization & Generalization
- Specialization: 하향식으로 속성을 상속하는 하위 집단을 구성하며 설계한다 (ISA; "is a" 삼각형 컴포넌트로 묘사된다)
-> primary key만 상속받을 경우, lower-lever, high-lever 두 가지에 접근하여 속성을 받아야 한다
-> 모든 속성을 상속받을 경우, not required 중복이 일어날 수 있다 (특히 total일 때)
- Generalization: 상향식 설계로, Specialization과 반대되는 개념이다
- 이는 Super Entity(superclass) - Sub Entity(subclass) 로 구성된다
- Specialization & Generalization 제약 조건
- 조건을 걸어 entity 생성 제약을 걸 수 있다 (condition-defined / user-defined)
- Disjoint: 한 entity가 하나의 lower-level entity set에 속한다 (entity들을 같은 삼각형에 연결)
/ Overlapping: 한 entity가 두 개 이상의 lower-level entity set에 속할 수 있다
- total: entity는 하나의 lower-level entity set에 속해야 한다
/ partial: entity는 여러 lower-level entity set에 속할 수 있다
- Total Summary
UML and Other E-R Notations
- UML; Unified Modeling Language
- 그래픽 모델링의 많은 구성 요소 (주로 객체 지향)
- E-R Diagram과 비슷하지만, 몇몇이 다르다.
- Chen, IDE1FX, ...
Reduction to Relation Schemas
이제는 E-R Diagram을 Table(관계형 모델)로 구성해야 한다. 보통은 자동적으로 이루어진다
- Relationship Set 표현
1. 각 entity의 primary keys로 구성한다. 이는 cardinality에 상관 없이 항상 동작한다
2. (one-to-many, many-to-one 이거나 many side가 total 일 때) relationship set에 생성하지 않고, one 측의 primary key를 다른 쪽에 추가한다
▪ 일대일 관계 집합의 경우, 어느 쪽이든 "many"가 될 수 있습니다. 즉, 두 entity set에 해당하는 table 중 하나에 추가 attribute을 추가할 수 있다
▪ many 쪽이 partial 한 경우, schema를 many 쪽에 해당하는 추가 attribute로 바꾸면 null 값이 발생할 수 있다
▪ weak entity set을 identifying strong entity set 에 연결하는 relationship set은 schema는 중복된다
- Composite, Multivalued Attributes
- multivalued attributes를 무시하면, instructor schema는 다음과 같다
instructor(
ID,
first_name,
middle_initial,
last_name,
street_number,
street_name,
apt_number,
city,
state,
zip_code,
date_of_birth
)
- multivalued attribute는 schema EM(엔티티-다중값) 상의 관계의 각 튜플에 매핑된다. ex) (222, 567-6940) and (222, 869-1641)
Design Issues
- attribute에 추가 정보를 허용하거나, 다수의 값이 있을 때 entity를 분리한다
- entity 간의 동작을 relationship set로 지정한다
- relationship attributes의 여부
- 여러 entities가 single relationship에 참여하는 것은 n-ary relationship set으로 보여준다 (converting non-binary relationships to binary form)
- 두 개의 partial 한 binary relationship으로 나눌 수 있다 (그러나 proj_guide 같은 경우는 non-binary가 자연스럽다)
'DB' 카테고리의 다른 글
[DB][데이터베이스] 7-1. DB Design / DB 설계 (0) | 2021.11.29 |
---|---|
[DB][데이터베이스] 5. Advanced SQL / 고급 sql (0) | 2021.11.26 |
[DB][데이터베이스] 4. Intermediate SQL / 중간 단계의 sql (0) | 2021.11.26 |
[DB][데이터베이스] 3. SQL / sql의 기본 문법 (0) | 2021.10.28 |
[DB][데이터베이스] 1. Database Systems / 데이터베이스 시스템 (0) | 2021.10.07 |