출처: https://3months.tistory.com/307 [Deep Play]

4-1/데이터베이스시스템

Chapter 2 : Reduction to Relation Schemas

코딩하는 랄뚜기 2022. 3. 28. 20:55

Reduction to Relation Schemas

 

ER model을 만들었다면 Relation Schema로 표현 할 줄 알아야 한다.

각각의 entity set과 relationship set은 unique schema가 있다.

각각의 schema는 unique name으로 이루어진 column들을 가지고 있다.

 


 

Representing Entity Sets

 

Strong entity set은 속성이 변하지 않고 schema가 된다.

Weak entity set은 identifying strong entity set의 primary key를 포함하여 schema가 된다.

 

※예시

 

Strong entity set : course(course_id,title,credits)

Weak entity set : section(course_id,sec_id,semester,year)

 


 

Representation of Entity Sets with Composite Attributes

 

Composite attribute를 schema로 나타낼 때는 앞에 '부모 속성_'을 붙여서 나타낸다.

하지만 중복이 일어나지 않는다면 그냥 써도 괜찮다.

 

※예시

Instructor(ID,first_name,middle_initial,last_name,street_number,street_name,apt_number,city,state,zip,date_of_birth)

 


Representation of Entity Sets with Multivalued Attributes

 

Multivalued Attribute는 Entity에 포함되는 것이 아니라 Entity의 primary key를 가진 새로운 schema로 표현하게 된다.

 

※예시

inst_phone=(ID,phone_number)

 

Entity에 속성이 multivalued attribute 밖에 없는 경우는 어떻게 할까?

 

time slot (time slot id, day, start time, endtime) 으로 나타내면 된다.

time slot id로 충분히 primary key가 될 수 있지만 왜 day와 start time까지 들어가는지는 모르겠다.. 아는 사람??

 


 

Representing Relationship Sets

 

 

Many-to-many relationship일 경우 두 entity의 pirmary key와 relation set의 속성을 합쳐서 만든다.

advisor=(s_id,i_id)

 


 

Redundancy of Schemas

 

Many-to-one relationship에서 many가 total일 경우 one의 primary key를 many에 추가해주면 된다.

total이 아닐 경우 null이 extra attribute로 들어가게 된다.

 

※예시

instructor(ID, name, salary, dept_name)

student(ID, name, tot_cred, dept_name)

 

One-to-one일 경우 한 쪽이 many 역할을 해주면 된다.(양쪽 다 다른 쪽의 pirmary key가 추가 될 수 있음)

 

Many-to-one에 total이어도 weak set entityidentifying relationship 이라면 이미 weak set entity를 표현하는데 strong set entity의 primary key를 포함한다.

'4-1 > 데이터베이스시스템' 카테고리의 다른 글

Chapter 6 : ER Model  (0) 2022.03.21
Chapter2 : Relational Algebra  (0) 2022.03.18
Chapter 2 Relation, Key  (1) 2022.03.14