Your SlideShare is downloading. ×
0
Ch4 Relational Mapping
Ch4 Relational Mapping
Ch4 Relational Mapping
Ch4 Relational Mapping
Ch4 Relational Mapping
Ch4 Relational Mapping
Ch4 Relational Mapping
Ch4 Relational Mapping
Ch4 Relational Mapping
Ch4 Relational Mapping
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ch4 Relational Mapping

694

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
694
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. CH4 Relational Mappong
  • 2. 步驟一:將各個實體畫出,並加上屬性,並將主鍵標為 PK ( 組合屬性為 Name 、 Fname 、 Minit 、 Lname ,則 Name 不需要加上去,如上所示 ) Employee Ssn Bdate Name Fname Minit Lname Address Salary Sex Employee Eependents_of Dependents_of 1 N Name Sex Birth_date Relationship PK Supervision 1 Supervisor N Superises Sex Salary Address Bdate Ssn Lname Minit Fname
  • 3. Employee FK PK 步驟二:將弱實體前,加上強實體的主鍵,成為外來鍵 步驟三:下頁說明->為了配合圖形,先說明步驟四 步驟四:若有 1:N 時,將 1 那邊實體的主鍵, 加到 N 那邊成為外來鍵 ( 若是遞迴關係,則將主鍵從新命名, 原因:為了避免在同一個欄位出現兩個相同的 ssn) FK PK PK ( 因此原本是 ssn ,從新命名後變成 Super_ssn) Employee Dependent 請參考前一頁投影片上的 ER 圖 Sex Salary Address Bdate Ssn Lname Minit Fname Relationship Birth_date Sex Name Employee_ssn Super_ssn Sex Salary Address Bdate Ssn Lname Minit Fname
  • 4. Department Name Locations Number Manages 1 1 步驟三: 1 對 1 時,將任一個實體的主鍵 加到另一邊上,成為外來鍵 PS :若是如上圖所以,有一邊是完全參予 的話,則將 1 條線上實體的主鍵,加 到 2 條線時那邊成為外來鍵 PK FK Department 如上圖,將 employee 的主鍵 放到 department 當外來鍵 Number Name Employee_ssn
  • 5. <ul><li>步驟五: N 對 M 時,將其中的 關係 轉變成新的關聯表,並將 N 和 M 的實體之主鍵放上去成為外來鍵 </li></ul>Works_on Project N M Location Number Name Hours Works_on FK Project FK PK Hours Project_name Employee_ssn
  • 6. Locations 步驟六: 如下圖 ,將多值屬性再創一個關連表, 且把自身當成外來鍵 ( 例: Locations_ 名稱 ) ,再加上原實體的主鍵形成外來鍵, 兩個外來鍵合成一個主鍵 R1 E1 E2 E3 e1 e2 e3 r1 步驟七: 如上圖 多元關係,將關係轉變成新的 關聯表,並將關係上連結的實體的主鍵 放上去變成外來鍵,外來鍵加起來就是主鍵 FK FK PK Locations_ 名稱 Department_name
  • 7. <ul><li>E1 </li></ul><ul><li>E2 </li></ul><ul><li>E3 </li></ul><ul><li>E0 </li></ul>E1 E3 E2 E0 e1 e2 e3 eo d e1 eo e2 eo eo e3 eo PK FK PK PK PK FK FK 步驟八:主類別、次類別 將實體和實體上的屬性畫出來,並在子類別加上超類別的主鍵 Step 8: Options for Mapping Specialization or Generalization
  • 8. <ul><li>E9 </li></ul><ul><li>E1 </li></ul><ul><li>E2 </li></ul>E1 E9 E2 u a1 a2 b1 b2 e9 e9 e9 b2 b1 a1 a2 步驟九 A :若兩實體均沒有共同屬性,則 實體 E9 產生一個屬性,並在 E1 和 E2 加上成為外來鍵 FK FK e9 PK Step 9: Mapping of Union Types ( Categories )
  • 9. <ul><li>E10 </li></ul><ul><li>E3 </li></ul><ul><li>E4 </li></ul>E3 E10 E4 ∩ c2 c1 u1 d2 d1 u1 ee2 c1 c2 u1 u1 d2 d1 u1 ee2 FK 步驟九 B :若兩實體有共同屬性,則 實體 E10 抓住共同屬性 來當外來鍵 Step 9: Mapping of Union Types ( Categories )
  • 10. 大 家 加 油 如有錯誤,請提出指教 ~

×