incastle의 콩나물
Database Concepts Chapter 4. Data Modeling and the Entity-Relationship Model 본문
Database Concepts Chapter 4. Data Modeling and the Entity-Relationship Model
incastle 2019. 5. 31. 21:06데이터베이스 이론 및 실습 정재윤 교수님 수업 (19-1)
Requirements Analysis(중요한지는 모르겠지만 일단 적어는 둠)
- User interviews, Forms, Reports, Queries, Use cases, Business rules
- These requirements must be transformed into a data model.
Entity Relationship(E-R) Data Model
Entity | Table |
attribute | column |
identifier | primary key |
relationship | foreign key |
Entity class | table design |
entity instances | records |
* Entities of a given type are grouped into an entity class
* Entity class is a collection of entities and is described by the structure of the entities in that class.
* 큰 차이점 : Entity 사이의 관계를 표현할 때 foreign key를 사용하지 않아도 됨. 그냥 관계가 존재한다, 안한다만을 선을 연결지어서 표현. 그래서 슈퍼 쉽다~ 추후 실제로 db를 설계하면서 이를 찾아줌.
Identifier
- Entity instances는 identifiers를 갖는다.
- An identifier will identify a particular instance in the entity class.
Identifier Types
- Uniqueness : identifier가 unique 할 수 있고 nonunique 할 수 도 있다.
- Composite : 2개 이상의 attribute를 조합해서 identifier로 사용 가능
* identifier vs key(relation model에서)
>> identifier는 여러 개로 지정 가능, 이게 relation model에서 key로 작용 할 수도 있고, 안할 수도 있고 내 맘임
>> primary, candidate key는 uniqueness를 보장함, identifier는 아님
Relationships
- Entities는 서로 relationship이 존재할 수 있다.
- Relationship degree는 entity의 수로 정의 된다.
- degree 2 is a binary relationship
- degree 3 is a ternary relationship
relationship 종류
- one to one
- one to many
- many to many
Maximum Cardinality
- entity끼리 관계를 맺을 때 그 안의 instance들 사이에 최대로 맺을 수 있는 instance의 수 (음식점이 최대 몇 개의 요리 가짓수를 가질 수 있나?)
- 0, many, or oher some fixed number.
Minimum Cardinality
- number of entity instances that must participate in a relationship instance.
- these values typically assume a value of zero(optional, 아예 없어도 된다는 뜻) or one(mandatory, 적어도 하나는 있어야 한다.)
HAS-A 관계
- each entity instance has a relationship to second enity instance.
- item has a supplier, supplier has a item
Crow's Foot Symbols
Weak Entity
- weak entity is an entity that cannot exist in the database without the existence on another entity.
- Any entity that is not a weak entity is called a strong entity
ID-Dependent Weak Entities
- weak entity인데 parent entity 없이 존재할 수 없는 entity.
- composite identifier를 갖음.
- the first part of the identifier is the identifier for the strong entity(부모의 identifier라고 생각하면 될 듯)
- the second part of the identifier is the identifier for the weak entity itself( 자신의 identifier라고 생각하면 될 듯)
- 실선으로 표시
- you cannot add an ID-dependent entity instance until the parent entity instnace is created, and you delete the parent instance you must elete all the ID-dependent entity instances as well.
non-id-dependent Weak Entity
- strong과 weak entity 사이의 관계인데 weak인 친구가 non-id-dependent야.
- single or composite identifier를 갖는다.
- parent entity의 identifier는 weak entity에서 foreign key로 사용된다.
- 점선으로 표시
* 모든 id-dependent entities는 weak entity이지만 모든 weak entity가 id-dependent는 아니다.
Subtype Entities
- subtype entity is a special case of another entity called its supertype.
- In some cases, an attribute of the supertype may include which of the subtypes is appropriate for a given instance
>>This attribute is called a discriminator.
- subtypes can be exclusive or inclusive
- isGradeStudent => discriminater라고 함.
- discriminator : An attribute that determines which subtype is appropriate is called a discriminator
Is-A relationships
- The relationships that connect supertypes and subtypes are called IS-A realtionships.
- Subtype is the same entity as the supertype.
- The identifier of a supertype and all of its subtypes is the same attribute.
- has a 관계에서는 identifier가 두 개의 entities가 다르다.
Recursive Relationships
- have an relationship to itself
- 페이스북 친구 관계 같은 느낌
'19-1 대학 수업 > 데이터베이스 이론 및 실습' 카테고리의 다른 글
Database Concepts Chapter 6. Database Administration (0) | 2019.06.01 |
---|---|
Database Concepts Chapter 5. Database Design (0) | 2019.06.01 |
Database Concepts Chapter 3. SQL (0) | 2019.04.22 |
Database Concepts Chapter 2. The Relational Model (0) | 2019.04.21 |
Database Concepts Chapter 1. Getting Started (0) | 2019.04.21 |