【数据库基础】EER图(Enhanced Entity-Relationship Modelling)
目錄
1. 為什么需要EER model?
什么時候用EER?
2. Specialization / Generalization 特化和概化
特化和概化的兩種約束
1.Participation constraint 參與性約束
2.Disjoint constraint 相關性約束
范例
1. 為什么需要EER model?
? ? ? ? 如圖,staff有多種不同職務,而有的屬性值是某一種職務特有的,其余的職務對它并不關心(如只有Manager有mgrStart和bonus,只有Secretary需要在乎typingSpeed),
? ? ? ? 此時繪制實體關系圖可以在ER的基礎上更細分,將父類(superclass)STAFF按照屬性position值的不同下分出多個子類(subclass,和Java中的父子繼承相似):Manager,Assistant,Secretary,...等等,這就是 “加強的ER”
什么時候用EER?
When one or both of:
1. Attributes apply to some (but not all) instances of an entity.
一類實體中,只有一部分個體實例需要有這個屬性(其他個體就算有也都是空)
2. Instances of potential subclass participate in a relationship unique to that subclass;
有的關系只聯系于superclass下某一類subclass(放在下邊范例1的圖看,就是Manager和Branch那種情況)
2. Specialization / Generalization 特化和概化
Specialization: Process of maximizing differences between members of an entity by identifying their distinguishing characteristics; Potential subclass? (為爸爸找兒子 Generalization: Process of minimizing differences between entities by identifying their common characteristics; Potential superclass? (給兒子們找爸爸特化和概化的兩種約束
1.Participation constraint 參與性約束
“爸爸”是否必須也是個“孩子”?
Mandatory: member of superclass must be member of subclass Optional: member of superclass may be member of subclass.2.Disjoint constraint 相關性約束
“爸爸”可以是一個孩子,還是多個孩子?
Disjoint:member of superclass is member of at most one subclass ( or ). Non-disjoint:member of superclass can be member of more than one subclass ( and ).上述約束條件交叉組合,形成4種不同的概化特化情況:
范例
1. 由關系Staff、Branch等改寫來的EER,和第一個圖的情況相似:
Staff中,由屬性position值的不同可暫分3個subclass:Manager、Sales Personnel、Secretary,一個staff可能是三種職業中的任意一種,也可以都不是(還有別的職業),所以是{Optional,And};
由工時(全職?or 臨時工)不同可分為2個subclass:FullTimePermanent、PartTimeTemporary,?一個staff要么全職,要么臨時,沒有別的選擇,所以是{Mandatory,Or};
2. subclass也可以有subclass,一個subclass還可以有多個superclass(子類小奉先了屬于是)。
總結
以上是生活随笔為你收集整理的【数据库基础】EER图(Enhanced Entity-Relationship Modelling)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【扬尘监测系统】让扬尘管理迈向“智慧化”
- 下一篇: XCharts图表插件,LineChar