๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐“ก๐“ธ๐“ธ๐“ถ5: ๐’ฆ๐‘œ๐“‡๐‘’๐’ถ ๐’ฐ๐“ƒ๐’พ๐“‹/Database(COSE371)

[๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค] CH6. Database Design Using the E-R Model

0. INTRO

1. Design Phases

  1. Initial phase : ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์‚ฌ์šฉ์ž๊ฐ€ ํ•„์š”๋กœ ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ํŒŒ์•…ํ•˜๊ธฐ
  2. Second phase : conceptual design
    • data model์„ ์„ ํƒํ•ด์„œ ๊ฐœ๋…์„ ์ ์šฉํ•œ๋‹ค.
    • requirements๋ฅผ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ conceptual schema๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค. (ex. ER Model)
    • ๊ฐœ๋ฐœ์ด ์™„๋ฃŒ๋œ conceptual schema๋Š” ๊ธฐ์—…์˜ ๊ธฐ๋Šฅ ์š”๊ตฌ ์‚ฌํ•ญ์„ ๋‚˜ํƒ€๋‚ธ๋‹ค.
  3. Final Phase : ์ถ”์ƒ์ ์ธ data model์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ตฌํ˜„ํ•˜๊ธฐ
    • Logical Design : ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์Šคํ‚ค๋งˆ๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค. (conceptual schema(er diagram)์„ logical schema(relational schema)์— ๋Œ€์‘์‹œํ‚จ๋‹ค)
    • Physical Design : ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๋ฌผ๋ฆฌ์  ๊ตฌ์กฐ๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค.

2. Design Alternatives

๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค schema ๋””์ž์ธ์„ ํ•  ๋•Œ์—” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋‘๊ฐ€์ง€ ์‚ฌํ•ญ์„ ๊ผญ ํ”ผํ•˜๋„๋ก ๋งŒ๋“ค์ž

  • Incompleteness : ๋ถˆ์™„์ „์„ฑ. ์„ค๊ณ„๊ฐ€ ์ž˜๋ชป๋˜๋ฉด ๊ธฐ์—…์˜ ํŠน์ • ๋ถ€๋ถ„์„ ๋ชจ๋ธ๋งํ•˜๊ธฐ ์–ด๋ ต๊ฑฐ๋‚˜ ๋ถˆ๊ฐ€๋Šฅํ•  ์ˆ˜ ์žˆ๋‹ค!
  • Redundancy : ์ค‘๋ณต์„ฑ. ์ •๋ณด์˜ ์ค‘๋ณต์€ ์ง€์–‘ํ•˜์ž. ์ค‘๋ณต์œผ๋กœ ์ธํ•ด ์—ฌ๋Ÿฌ copy๋ณธ์˜ ๋ฐ์ดํ„ฐ์˜ ๋ถˆ์ผ์น˜๊ฐ€ ์ผ์–ด๋‚  ์ˆ˜ ์žˆ๋‹ค.

๋ฌผ๋ก , ์ด bad designs์„ ํ”ผํ•œ๋‹ค๊ณ  ๋์€ ์•„๋‹˜. ์šฐ๋ฆฌ๊ฐ€ ์„ ํƒํ•ด์•ผ ํ•  ์ข‹์€ ๋””์ž์ธ์ด ๋งค์šฐ๋งค์šฐ ๋งŽ์Œ

3. Design Approaches

  • entity relationship model
    : entity๋ฐ relation์˜ ์ง‘ํ•ฉ์œผ๋กœ enterprise๋ฅผ ๋ชจ๋ธ๋งํ•œ๋‹ค.
    • entity : enterprise์—์„œ ๋‹ค๋ฅธ objects๋ž‘ ๊ตฌ๋ถ„๋˜๋Š” 'thing' ๋˜๋Š” 'object'
    • relationship : entity๊ฐ„์˜ ์—ฐ๊ด€์„ฑ
      _entity-relationship diagram_์œผ๋กœ ๋„์‹ํ™”๋˜์–ด ํ‘œํ˜„๋จ.
      _Normalization Theory_๋กœ ์–ด๋–ค ๋””์ž์ธ์ด ๋‚˜์œ์ง€ ๊ณต์‹ํ™”ํ•˜๊ณ  ํ…Œ์ŠคํŠธ ํ•จ.

1. Outline of ER(Entity- Relationship) Model

  • ER data model์€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์„ค๊ณ„๋ฅผ ์šฉ์ดํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด ๊ฐœ๋ฐœ ๋˜์—ˆ๋‹ค.
    ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๋…ผ๋ฆฌ์  ๊ตฌ์กฐ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” enterprise schema์˜ specification์„ ํ—ˆ์šฉํ•จ
  • ER data model = entity sets, relationship sets, attributes๋กœ ๊ตฌ์„ฑ๋จ
  • ER model์€ ER diagram์ด๋ผ๋Š” ๋‹ค์ด์–ด๊ทธ๋žจ ํ‘œํ˜„๊ณผ๋„ ์—ฐ๊ด€๋˜์–ด ์žˆ๋‹ค. ์ด๊ฒƒ์€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์ „์ฒด ๋…ผ๋ฆฌ์  ๊ตฌ์กฐ๋ฅผ graphicallyํ•˜๊ฒŒ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค.

1. Entity sets

  • entity๋Š” ๋‹ค๋ฅธ objects์™€ ๊ตฌ๋ถ„๋˜๋Š” ํ•˜๋‚˜์˜ object.
  • entity sets์€ ๊ฐ™์€ type์ด๋‚˜ properties๋ฅผ ๊ฐ€์ง„ ์—”ํ‹ฐํ‹ฐ๋“ค์˜ ์ง‘ํ•ฉ!
  • ํ•˜๋‚˜์˜ ์—”ํ‹ฐํ‹ฐ๋Š” attribute์˜ ์ง‘ํ•ฉ์œผ๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค.
    ex. instructor = (ID, name, salary)
  • attribute์˜ ๋ถ€๋ถ„์ง‘ํ•ฉ์€ entity set์˜ primary key๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.

Representing Entity sets in ER Diagram

  1. entity set์€ ์ง์‚ฌ๊ฐํ˜•์œผ๋กœ ๋‚˜ํƒ€๋‚ธ๋‹ค
  2. attributes๋Š” ์ง์‚ฌ๊ฐํ˜• ์•ˆ์— ๋‚˜์—ดํ•ด์„œ ์ž‘์„ฑํ•œ๋‹ค.
  3. primary key์ธ attribute ์—๋Š” ๋ฐ‘์ค„์„ ๊ธ‹๋Š”๋‹ค.

2. Relationship sets

  • relationship์€ entity๋“ค์˜ association!!
  • ํ•˜๋‚˜์˜ relationship set๋Š” n>=2์ธ entity๊ฐ„์˜ ์ˆ˜ํ•™์  relation์ด๋‹ค.

ex ) (45522, 32321) ∈ advisor

  • ๊ทธ๋ฆผ์œผ๋กœ ๊ทธ๋ฆฌ๋ฉด related entity๋ผ๋ฆฌ ์„ ์„ ๊ทธ์–ด์ค„ ์ˆ˜ ์žˆ๋‹ค.

Representing Relationship sets via ER Diagrams

Diamond = relationship sets

+) relationship set์™€ attribute๋ฅผ ์—ฐ๊ฒฐํ•  ์ˆ˜๋„ ์žˆ์Œ.
์˜ˆ๋ฅผ ๋“ค์–ด, instructor๊ณผ student ์‚ฌ์ด์— advisor๋ผ๋Š” relationship์ด ์žˆ๋‹ค๊ณ  ํ–ˆ์„ ๋•Œ,
์ด๋“ค์ด ์—ฐ๊ฒฐ๋˜๊ธฐ ์‹œ์ž‘ํ•œ ์‹œ์ ์„ attribute๋กœ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.

Roles

  • ๊ฐ™์€ entity ์•ˆ์—์„œ์˜ relationship์„ ๋งํ•จ (๊ผญ ์„œ๋กœ ๋‹ค๋ฅธ ์—”ํ‹ฐํ‹ฐ์ผ ํ•„์š” X)

Degree of a Relationship set

  1. Binary relationship
    • ๋‘ ๊ฐœ์˜ entity๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Œ
    • ๋Œ€๋ถ€๋ถ„์˜ ๋””๋น„ ์‹œ์Šคํ…œ์˜ relationship set๋Š” binary์ž„
    1. Non-binary relationship sets
      ๋ฌผ๋ก  ์„ธ ๊ฐœ ์ด์ƒ์˜ entity set์„ ๊ฐ–๋Š” ๊ฒฝ์šฐ๋„ ๋“œ๋ฌผ์ง€๋งŒ ์žˆ๋‹ค.
      ex) student๋Š” instructor ์•„๋ž˜์—์„œ project๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค. (์‚ผ์›๊ด€๊ณ„)

3. Complex Attributes

Attribute types

  • simple and composite attributes
    ex) ์ฃผ์†Œ : composite attributes (์‹œ, ๋™, ์ƒ์„ธ์ฃผ์†Œ ..)
  • singled-valued and multivalued attributes
    ex) ํฐ ๋ฒˆํ˜ธ : multivalued attribute
  • derived attributes : ๋‹ค๋ฅธ attribute๋กœ ๋ถ€ํ„ฐ ์–ป์–ด์ง€๋Š” ๊ฒƒ
    ex) ์ƒ์ผ --> ๋‚ ์งœ

Domain : ๊ฐ attribute๊ฐ€ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋Š” ๊ฐ’์˜ ์ง‘ํ•ฉ

4. Mapping Cardinality Constarints

์ฐธ๊ณ  ) ER Diagram ์—์„œ๋Š” one = ํ™”์‚ดํ‘œ, many = ์ง์„  ์œผ๋กœ ํ‘œ์‹œํ•œ๋‹ค.

One to one

One to many

instructor์—๋Š” ์—ฌ๋Ÿฌ๋ช…์˜ ํ•™์ƒ(0~n๋ช…)์ด ์žˆ๊ณ 
student์—๋Š” ์ตœ๋Œ€ ํ•œ๋ช…์˜ ๊ต์ˆ˜์ž๊ฐ€ ์—ฐ๊ฒฐ๋œ๋‹ค.

Many to one

๋ฐ˜๋Œ€๋กœ instructor๋‹น ํ•™์ƒ ํ•œ ๋ช…,
ํ•™์ƒ ํ•œ ๋ช…๋‹น instructor ์—ฌ๋Ÿฌ ๋ช…

Many to many

ํ—ท๊ฐˆ๋ฆฌ๋ฉด ๊ทธ๋ฆผ์„ ๊ทธ๋ ค๋†“๊ณ  ์ƒ๊ฐํ•˜์ž. many ์ชฝ์ด ์—ฌ๋Ÿฌ๊ฐœ !!!
์„ ์œผ๋กœ ๋ณด๋ฉด one ํ•˜๋‚˜์—์„œ many์ชฝ์œผ๋กœ ์„ ์ด ์—ฌ๋Ÿฌ๊ฐœ๋กœ ๊ฐ.

5. Total and Partial Participation

Total participation (๋‘ ์ค„) : ๋ชจ๋“  entity๊ฐ€ ๋ฐ˜๋Œ€ํŽธ ๋‹ค๋ฅธ entity์™€ ๋ฌด์กฐ๊ฑด ํ•˜๋‚˜์”ฉ์€ ์—ฐ๊ฒฐ๋˜์–ด์•ผ ํ•จ.

๋ชจ๋“  ํ•™์ƒ์€ ๋ฌด์กฐ๊ฑด ์ตœ์†Œ ํ•œ ๋ช…์˜ instructor๊ณผ ์—ฐ๊ฒฐ๋˜์–ด์•ผ ํ•จ.

Partial participation : ์—ฐ๊ฒฐ๋  ์ˆ˜๋„ ์žˆ๊ณ  ์•„๋‹ ์ˆ˜๋„ ์žˆ์Œ

๊ต์ˆ˜๋‹˜์€ student๋ฅผ ๋ฐฐ์ •๋ฐ›์ง€ ์•Š์•„๋„ ๋จ

์ข€ ๋” ๋ณต์žกํ•œ constraints

-> ์—ฐ๊ฒฐํ•  relation์˜ ์ตœ๋Œ€/์ตœ์†Œ ๊ฐœ์ˆ˜๋ฅผ ์ง€์ •ํ•ด์„œ ์“ธ ์ˆ˜ ์žˆ๋‹ค.

0.. * : partial
1..1 : ์ตœ๋Œ€ ์—ฐ๊ฒฐ์ด 1์ธ total

6. Primary key

1. Entity sets

Key of an entity : ์—”ํ‹ฐํ‹ฐ๋ฅผ ์„œ๋กœ ๊ตฌ๋ณ„ํ•  ์ˆ˜ ์žˆ๋Š” attribute์˜ ์ง‘ํ•ฉ
super key -> candidate key -> primary key

entity set์˜ ๋‘ entity๋Š” ๋ชจ๋“  attribute์— ๋Œ€ํ•ด ๋™์ผํ•œ ๊ฐ’์„ ๊ฐ€์งˆ ์ˆ˜ ์—†๋‹ค. ์‹๋ณ„ ๊ฐ€๋Šฅํ•ด์•ผ ํ•œ๋‹ค.

2. Relationship sets

  • relationship set์˜ ์—ฌ๋Ÿฌ relation์„ ๊ตฌ๋ถ„ํ•˜๊ธฐ ์œ„ํ•ด์„œ relation set์— ์žˆ๋Š” entity๋“ค์˜ primary key๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  • mapping cardinality์— ๋”ฐ๋ผ primary key ์„ ํƒ์ด ๋‹ฌ๋ผ์ง„๋‹ค.
  1. Many-to-Many : ์–‘ ์ชฝ์˜ primary key๋ฅผ ๋‘˜ ๋‹ค ์‚ฌ์šฉํ•œ๋‹ค.
  2. One-to-Many : Many ์ชฝ์— ์žˆ๋Š” primary key๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  3. Many-to-One : Many ์ชฝ์— ์žˆ๋Š” primary key๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  4. One-to-One : ๋‘˜ ์ค‘ ํ•˜๋‚˜ ๊ณ ๋ฅด๋ฉด ๋œ๋‹ค.
Cardinality Constraints on Ternary Relationship
  • cardinality constraints๋Š” binary ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ 3 ์ด์ƒ์˜ ternary relationship์—์„œ๋„ ์“ธ ์ˆ˜ ์žˆ๋‹ค.
    ์ด ๋•Œ ํ™”์‚ดํ‘œ๋Š” ํ•˜๋‚˜!
    ex) proj_guid์—์„œ ๊ฐ•์‚ฌ๋กœ์˜ ํ™”์‚ดํ‘œ๋Š” ๊ฐ ํ•™์ƒ์ด ํ”„๋กœ์ ํŠธ์— ๋Œ€ํ•ด ์ตœ๋Œ€ ํ•œ ๋ช…์˜ ๊ฐ€์ด๋“œ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Œ์„ ๋‚˜ํƒ€๋ƒ„
  • ํ™”์‚ดํ‘œ๊ฐ€ ๋งŒ์•ฝ ๋‘ ๊ฐœ ์ด์ƒ์ธ ๊ฒฝ์šฐ ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์œผ๋กœ ์˜๋ฏธ๋ฅผ ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. 
    1. ๊ฐ A entity๋Š” ๊ณ ์œ ํ•œ B์™€ C entity์™€ ์—ฐ๊ด€๋˜์–ด ์žˆ๋‹ค.
    2. (A, B)์˜ ๊ฐ entity ์Œ์€ ๊ณ ์œ ํ•œ C entity์™€ ์—ฐ๊ฒฐ๋˜๊ณ , (A,C)๋Š” ๊ณ ์œ ํ•œ B entity์™€ ์—ฐ๊ฒฐ๋œ๋‹ค.
    --> ์ด๋Ÿฐ ํ˜ผ๋ž€์„ ๋ง‰๊ธฐ ์œ„ํ•ด ํ™”์‚ดํ‘œ๋Š” ํ•˜๋‚˜๋งŒ!!!! (one์€ ํ•˜๋‚˜๋งŒ!!)
  • ->C
  • ex) A->B

3. Weak entity sets

  • section entity์™€ course entity๊ฐ€ ์žˆ๊ณ , ์ด ๋‘˜์„ ์ž‡๋Š” sec_course relation์„ ์ƒ๊ฐํ•ด๋ณด์ž.
    ์ด๋ฏธ section์—๋Š” course_id๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— sec_course๋ฅผ ๋งŒ๋“ค ๊ฒฝ์šฐ, ์ •๋ณด๊ฐ€ ์ค‘๋ณต๋˜๊ฒŒ ๋œ๋‹ค.
    ๊ทธ๋ ‡๋‹ค๊ณ  ํ•ด์„œ sec_course๋ฅผ ์—†์• ๊ณ  section๊ณผ course๊ฐ„์˜ ๊ด€๊ณ„๊ฐ€ attribute์—๋งŒ ๋ช…์‹œ๋˜๊ฒŒ ๋งŒ๋“œ๋Š” ๊ฒƒ์€ ๋ฐ”๋žŒ์งํ•˜์ง€ ์•Š๋‹ค.
  • ๋Œ€์•ˆ์ฑ…์€ course_id attribute๋ฅผ section entity์— ์ถ”๊ฐ€ํ•˜์ง€ ์•Š๊ณ  ๋‚˜๋จธ์ง€ ํŠน์„ฑ๋งŒ ์ถ”๊ฐ€ํ•ด ๋ช…์‹œํ•˜๋Š” ๊ฒƒ์ด๋‹ค.
    ๊ทผ๋ฐ ์ด๋Œ€๋กœ ๋†”๋‘๋ฉด ํŠน์ • entity๋ฅผ ์‹๋ณ„ํ•  ์ˆ˜๊ฐ€ ์—†๋‹ค. attribute๊ฐ€ ๋ถ€์กฑํ•˜๋‹ˆ๊นŒ!
  • ์ด ํ•ด๊ฒฐ์ฑ…์ด ๋ฐ”๋กœ weak entity set์ž„
    sec_course๋ฅผ section entity๋ฅผ ์‹๋ณ„ํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ course_id๋ฅผ ์ œ๊ณตํ•˜๋Š” ํŠน์ˆ˜ ๊ด€๊ณ„๋กœ ๋งŒ๋“œ๋Š” ๊ฒƒ์ž„.
  • weak entity set์€ ์–ด๋–ค entity์— ์ข…์†๋œ entity๋ฅผ ๋งํ•จ.
    weak entity์™€ primary key๋ฅผ associatingํ•˜๋Š” ๋Œ€์‹ , weak entity๋ฅผ ์‹๋ณ„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” discriminator๋ผ๊ณ  ๋ถˆ๋ฆฌ๋Š” ์ถ”๊ฐ€ attributes์™€ identifying entity๋ฅผ ์‚ฌ์šฉํ•  ๊ฒƒ์ž„. (weak entity ์•ˆ์—์„œ์˜ primary key = discriminator ๋ผ๊ณ  ๋ณด๋ฉด ๋  ๋“ฏ)

Strong entity set : weak entity set ์ด ์•„๋‹Œ ๋ชจ๋“  entity set

  • ๋ชจ๋“  weak entity๋Š” ์‹๋ณ„ ๊ฐ€๋Šฅํ•œ ๋‹ค๋ฅธ entity set๊ณผ ์—ฐ๊ด€๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค. ์ฆ‰,
    existence dependent on the identifying entity set ์ด๋‹ค.
  • Identifying entity set์€ weak entity set์„ own ํ•œ๋‹ค๊ณ  ํ‘œํ˜„ํ•œ๋‹ค.
  • ๊ทธ๋ฆฌ๊ณ  ์ด๋Ÿฐ weak entity set๊ณผ identifying entity๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” relation์„ Identifying relationship ์ด๋ผ๊ณ  ํ•œ๋‹ค.
Expressing Weak entity sets
  • ER Diagram์—์„œ weak entity set์€ double ์ง์‚ฌ๊ฐํ˜•์œผ๋กœ ํ‘œํ˜„๋จ (๋‘ ์ค„์˜ ์ง์‚ฌ๊ฐํ˜•..)
  • discriminator์•„๋ž˜์—” ์ ์„ ์„ ๊ทธ์–ด์คŒ
  • weak entity set๊ณผ strong entity set์„ ์ด์–ด์ฃผ๋Š” relation์€ double diamond๋กœ ํ‘œ์‹œํ•จ

2. Reduction to Relation Schemas ( ER Diagram -> Schemas Diagrams )

1. Representing Entity sets

  1. Strong entity set : same.. ๊ทธ๋Œ€๋กœ ๋งŒ๋“œ์…ˆ
    Weak entity set : ์›๋ž˜ ๊ทธ attribute๋“ค์— ์ž์‹ ์ด ์†ํ•œ entity์˜ primary key ๋ฅผ ๊ฐ€์ ธ์™€์„œ table์„ ๋งŒ๋“ฆ
  2. Composite attributes : ๊ฐ€์žฅ ํ•˜์œ„์˜ attribution์„ ๋ชจ์•„์„œ ์‚ฌ์šฉํ•œ๋‹ค. ex. name -> first_name, last_name
    derived attributes : ๊ทธ๋ƒฅ ์—†์• ๋ฒ„๋ฆผ.
  3. multivalued attributes : ์ƒˆ ํ…Œ์ด๋ธ”์„ ๋งŒ๋“ ๋‹ค.
    entity E์˜ multivalued attribute M ์ด ์žˆ์„ ๊ฒฝ์šฐ, E์˜ Primary key์™€ M์˜ attribute๋ฅผ ๊ฐ€์ง€๊ณ  ์ƒˆ ํ…Œ์ด๋ธ”์„ ๋งŒ๋“ ๋‹ค.
    ex) inst_phone = (ID, phone_number)

2. Representing Relationship Sets

  1. Many-to-many relationship set์˜ ๊ฒฝ์šฐ, ๋‘ entity sets์˜ primary keys๋กœ table์„ ๊ตฌ์„ฑํ•œ๋‹ค.
  2. One-to-many relationship set๋Š” many ์ชฝ์—์„œ primary key๋งŒ ์žˆ์œผ๋ฉด ๋œ๋‹ค.
  3. One-to-one์€ ๋‘˜ ์ค‘ ์•„๋ฌด๊ฑฐ๋‚˜ ์„ ํƒํ•ด๋„ ์ƒ๊ด€ ์—†๋‹ค.

Redundancy of Schema

Many ์ชฝ์ด total์ธ Many to one์ด๋‚˜ one to many relationship sets์˜ ๊ฒฝ์šฐ, one side์˜ primary key๋ฅผ many side์— ์ถ”๊ฐ€ํ•ด์ฃผ๋Š” ๊ฒƒ ๋งŒ์œผ๋กœ๋„ ๋‘˜์˜ ๊ด€๊ณ„๋ฅผ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋‹ค. ์ฆ‰, ์ƒˆ ํ…Œ์ด๋ธ” ์•ˆ๋งŒ๋“ค๊ณ  attribute๋งŒ ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋จ. primary key๋„ ๊ตณ์ด ์•ˆ๋ฐ”๊ฟ”๋„ ๋จ.

One-to-one ๊ด€๊ณ„์—์„œ๋Š” ๋‘˜ ์ค‘ ํ•˜๋‚˜์˜ primary key๋ฅผ ๋‹ค๋ฅธ ํ•œ ์ชฝ์— ์ถ”๊ฐ€ํ•ด ์ฃผ๋ฉด ๋จ.
๋งŒ์•ฝ many side์—์„œ total์ด ์•„๋‹Œ partial์ผ ๊ฒฝ์šฐ์— ์ด many side ์ชฝ์—์„œ attribute๋ฅผ ์ถ”๊ฐ€ํ•  ๊ฒฝ์šฐ null ๊ฐ’์ด ์ฑ„์›Œ์งˆ ์ˆ˜๋„ ์žˆ์Œ

  • weak entity set๊ณผ strong entity set์„ ์—ฐ๊ฒฐํ•˜๋Š” relationship์— ํ•ด๋‹นํ•˜๋Š” schema๋Š” redundantํ•˜๋‹ค!

3. Extended ER Features

1. Specialization

Top-down design process : entity ๋‚ด์—์„œ sub-groupings์„ ์ง€์ •ํ•˜๋Š” ๊ฒƒ..?

  • sub grouping์€ ์ƒ์œ„ ๋ ˆ๋ฒจ entity์—๋Š” ์ ์šฉ๋˜์ง€ ์•Š๋Š” attributes๋‚˜ participate๋ฅผ ๊ฐ€์ง„ lower-level entity sets์ด ์™ผ๋‹ค.
  • ISA๋ผ๋Š” ์ด๋ฆ„์˜ triangle component๋กœ ํ‘œํ˜„๋œ๋‹ค.
  • attribute inheritance : lower level entity๋“ค์€ high level entity์˜ ๋ชจ๋“  attribute์™€ relationship participation์„ ์ƒ์† ๋ฐ›๋Š”๋‹ค.

ISA ๊ด€๊ณ„์—๋Š”

Overlapping : ๋‘ ๊ฐœ์˜ ์†์„ฑ์ด ๋™์‹œ์— ๊ฐ€๋Šฅ (๊ฒธํ•˜๊ธฐ ๊ฐ€๋Šฅ)

Disjoint : ๋ฌด์กฐ๊ฑด ๋‘˜ ์ค‘ ํ•˜๋‚˜. ๋™์‹œ ๋ถˆ๊ฐ€.

Representing Specialization via Schemas

Method 1

  • higher level entity ๋ฅผ schema๋กœ ๊ตฌ์„ฑํ•œ๋‹ค.
  • lower level entity๋ฅผ schema ๊ตฌ์„ฑํ•œ๋‹ค. ์ด ๋•Œ higher-level์˜ primary key๋ฅผ ํฌํ•จํ•œ๋‹ค.
  • ๋”ฐ๋ผ์„œ ํ•˜์œ„์—์„œ ์ƒ์œ„ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋ ค๋ฉด join ํ•ด์•ผํ•œ๋‹ค.
  • ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ๋‹จ๊ณ„๊ฐ€ ๊นŠ์–ด์งˆ ์ˆ˜๋ก ๋น„ํšจ์œจ์ ์ด๋‹ค.

Method 2

  • ํ•˜์œ„ ๋ ˆ๋ฒจ์— ์ƒ์œ„ ๋ ˆ๋ฒจ ์ •๋ณด๊นŒ์ง€ ๊ทธ๋ƒฅ ์‹น ๋‹ค ์ €์žฅํ•œ๋‹ค.
  • ์ •๋ณด์˜ ์ค‘๋ณต์ด ์ผ์–ด๋‚˜์ง€๋ฉด join ํ•  ํ•„์š”๋Š” ์—†์–ด์ง„๋‹ค.

2. Generalization

A bottom-up design process : ํ•˜์œ„ entity set์„ ์ด์šฉํ•ด ๊ณตํ†ต ๋ถ„๋ชจ๋ฅผ ์ฐพ์•„์„œ ์ƒ์œ„ entity๋ฅผ ๊ตฌ์„ฑํ•œ๋‹ค.
๊ตฌ์„ฑ๋œ ๊ฒฐ๊ณผ๋Š” specialization๊ณผ ๊ฐ™๋‹ค.

Completeness constraint

high-level entity set์ด ๋ฌด์กฐ๊ฑด lower-level entity set์— ์†ํ•ด์•ผ ํ•˜๋Š”์ง€๋ฅผ ์ง€์ •ํ•œ๋‹ค.

  • total : ๋ฌด์กฐ๊ฑด lower-level entity sets ์ค‘ ํ•˜๋‚˜์—” ์†ํ•ด์•ผ ํ•จ
  • partial : ์•ˆ ์†ํ•ด๋„ ๋จ. ๊ทธ lower leve entity ์™ธ์˜ ๋‹ค๋ฅธ ๊ฒƒ์ด ์žˆ์„ ์ˆ˜ ์žˆ์Œpartial generalization์ด ๊ธฐ๋ณธ์ด๋‹ค.
  • ํ™”์‚ดํ‘œ์— 'total'์ด๋ผ๊ณ  ์ ์Œ์œผ๋กœ์„œ ER Diagram ์ƒ์— ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ๋‹ค.
  • generalization์€ ํ•˜์œ„ entity set์˜ ๊ณตํ†ต์ ์œผ๋กœ ๋งŒ๋“ค์–ด์ง„๊ฑฐ๋ผ ๊ฑฐ์˜ ๋Œ€๋ถ€๋ถ„์€ total์ด๋‹ค.

4. Design Issues

1. Common Mistakes in ER Diagram

  • incorrect use of attribute (redundancy)
  • erroneous use of relationship attributes (multivalue)

Entities vs attributes

  1. entity set ์‚ฌ์šฉ : entity ์ชผ๊ฐœ๊ธฐ. (ํ•œ entity๊ฐ€ ์—ฌ๋Ÿฌ entity๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Œ)
  2. attribute ์ถ”๊ฐ€ : single value

Entities vs Relationship sets

  • relation์œผ๋กœ ๋ช…์‹œ์ ์œผ๋กœ ์ด์„์ง€, ์•„๋‹ˆ๋ฉด ๋ฐ”๋กœ ์ด์„์ง€ ๊ฒฐ์ •
  • entity ๊ฐ„์— ์ผ์–ด๋‚˜๋Š” action์€ relationship์œผ๋กœ ์ง€์ •ํ•˜๋ผ๋Š”๊ฒŒ ์ผ๋‹จ ๊ถŒ์žฅ๋จ.

Binary vs Non-binary relationships

  • non binary relationship์€ ์—ฌ๋Ÿฌ ๊ตฌ๋ถ„๋œ binary relationship sets๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ๊ธด ํ•œ๋ฐ, n-ary relationship์ด ๊ฐ entity๋“ค์ด ํ•˜๋‚˜์˜ relation์— ์ฐธ์—ฌํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์ž˜ ๋ณด์—ฌ์คŒ
  • ์–ด๋–ค relationship์€ non-binary๋ณด๋‹ค binary ์“ฐ๋Š” ๊ฒƒ์ด ์ข‹์„ ์ˆ˜ ์žˆ์Œ

ex. parent๋ผ๋Š” ternary relationship : child, father, mother
์ด๊ฑด ๋‘๊ฐœ์˜ binary relation์œผ๋กœ ์ชผ๊ฐฌ . child - father / child - mother

๊ทผ๋ฐ ๋ญ ๋‹ค ๋˜๋Š” ๊ฑด ์•„๋‹˜

Convertubg Non-binary Relationship to Binary form

  • ์ผ๋ฐ˜์ ์œผ๋กœ non binary ๊ด€๊ณ„๋Š” binary ๊ด€๊ณ„๋ฅผ ์ด์šฉํ•ด ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋‹ค.
  • A,B,C ์‚ฌ์ด์˜ Relation R์„ entity set E๋กœ ๋ฐ”๊พธ๊ณ , relation์„ A-E, B-E, C-E๋กœ ์ชผ๊ฐ ๋‹ค.
  • E์— identifying attribute๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ , R์˜ attribute๋ฅผ E์— ์ถ”๊ฐ€ํ•œ๋‹ค.

ER Design Decisions

  1. ์–ด๋–ค object๋ฅผ ๋‚˜ํƒ€๋‚ด๊ธฐ ์œ„ํ•ด attribute๋ฅผ ์ถ”๊ฐ€ํ•  ๊ฒƒ์ธ์ง€, entity set์œผ๋กœ ๋‚˜ํƒ€๋‚ผ ๊ฒƒ์ธ์ง€
  2. ์‹ค์ œ ์„ธ๊ณ„์˜ ๊ฐœ๋…์„ entity set๋˜๋Š” relationship set ์ค‘ ๋ฌด์—‡์ด ๊ฐ€์žฅ ์ž˜ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋Š”์ง€
  3. ternary relationship ์„ ์“ธ ๊ฒƒ์ธ์ง€ binary relationship์„ ์“ธ ๊ฒƒ์ธ์ง€
  4. strong ๋˜๋Š” weak entity set์˜ ์‚ฌ์šฉ
  5. specialization ๋˜๋Š” generalization์˜ ์‚ฌ์šฉ