entity-relationship modeling - walailak universitymit.wu.ac.th/mit/images/editor/files/dbs 2556...
TRANSCRIPT
![Page 1: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/1.jpg)
Connolly, Thomas and Begg, Carolyn. 2010. Database Systems: A
Practical Approach to Design, Implementation, and Management. 5th
Ed. Pearson Education.
Entity-relationship modeling
ITM-661 ระบบฐานขอ้มลู (Database system) 1
![Page 2: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/2.jpg)
... การจะพัฒนาทกุสิง่ทกุอยา่งใหเ้จรญินัน้จะตอ้งสรา้งและเสรมิขึน้จากพืน้ฐานเดมิทีม่อียูก่อ่นทัง้สิน้ ถา้พืน้ฐานไมด่ ีหรอืคลอนแคลนบกพรอ่งแลว้ ทีจ่ะเพิม่เตมิเสรมิตอ่ใหเ้จรญิขึน้ไปอกีนัน้ ยากนักทีจ่ะท าได ้จงึควรจะเขา้ใจใหแ้จง้ชดัวา่ นอกจากจะมุง่สรา้งความเจรญิแลว้ ยงัตอ้งพยายามรักษาพืน้ฐานใหม้ัน่คง ไม่บกพรอ่งพรอ้มๆกนัไปดว้ย..
พระบรมราโชวาทของพระบาทสมเด็จพระเจา้อยูห่วั
ในพธิพีระราชทานปรญิญาบตัร จฬุาลงกรณ์มหาวทิยาลยั
10 ก.ค.2523
2
![Page 3: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/3.jpg)
Objectives
How to use Entity–Relationship (ER) modeling in database design.
Basic concepts associated with ER model.
Diagrammatic technique for displaying ER model using Unified Modeling Language (UML).
How to identify and resolve problems with ER models called connection traps.
How to build an ER model from a requirements specification.
3
![Page 4: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/4.jpg)
เนือ้หา
Entity-relationship modeling
Entity types
Relationship types
Attributes
Structural constraints
Problems with ER model
4
![Page 5: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/5.jpg)
Entity-relationship diagram (ERD)
ERD เป็นเครือ่งมอืทีใ่ชป้ระกอบการวเิคราะหแ์ละการจ าลองขอ้มลู ผูท้ีค่ดิคน้แบบจ าลองนีค้อื Dr. Peter Chen ในปีคศ. 1976
ปัจจบุนันีก้็ยงัไดค้วามนยิมในการใชง้านอยา่งแพรห่ลาย รวมทัง้เป็นพืน้ฐานของการพัฒนาเครือ่งมอืในการพัฒนาระบบ (CASE tool) และ Diagram แบบอืน่ๆเชน่ UML ซึง่เป็นเครือ่งมอืในการวเิคราะหแ์ละออกแบบเชงิวตัถ ุ
![Page 6: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/6.jpg)
ERD เป็นแบบจ าลองขอ้มลูทีน่ยิมใชใ้นระดบั Conceptual
เนน้การอธบิายทีเ่กีย่วขอ้งกับ Entity, Relationship และ Attribute
รวมถงึความหมาย (Semantic) หรอืเงือ่นไขอืน่ของขอ้มลูดว้ย
นักวเิคราะหร์ะบบใช ้ERD เพือ่วเิคราะหก์ารใชข้อ้มลูของผูใ้ช ้
กลุม่ตา่งๆ
6
![Page 7: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/7.jpg)
First-cut ERD for Staff user views of DreamHome
7
![Page 8: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/8.jpg)
ERD of Branch user views of DreamHome with PK
8
![Page 9: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/9.jpg)
ER diagram for Staff user views of DreamHome with PK
9
![Page 10: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/10.jpg)
Conceptual data model for Staff user view showing all attributes
10
![Page 11: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/11.jpg)
ขอ้สงัเกต
การเขยีน ERD สามารถเขยีนโดยมรีายละเอยีดตา่งกนั
Entity – relationship
Entity – relationship with PK
Entity – relationship – attribute
11
![Page 12: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/12.jpg)
Concepts of the ER Model
Entity types
Relationship types
Attributes
12
![Page 13: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/13.jpg)
Entity Type
Entity type
Group of objects with same properties, identified by enterprise as having an independent existence.
student(id, name, sex, DOB)
Entity occurrence
Uniquely identifiable object of an entity type.
4810524, สมชาย รักด,ี ช, 16/05/2534
4810547, สมศร ีมสีขุ, ญ, 04/11/2535
4810512, ขนษิฐา ใจเย็น, ญ, 26/12/2535
13
![Page 14: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/14.jpg)
ตวัอยา่ง
ผูค้น เชน่ พนักงาน ลกูคา้ ผูป้ระมลู ผูส้มคัร ผูป่้วย ผูต้อ้งหา
สถานทีเ่ชน่ บรษัิท โรงงาน อาคาร โรงแรม โรงพยาบาล โรงเรยีน สถานตี ารวจ สถานทีเ่กดิเหต ุสนามเทนนสิ
สิง่ของทีจั่บตอ้งได ้เชน่ สนิคา้ ยา วตัถดุบิ คอมพวิเตอร ์อาหาร ยานพาหนะ เครือ่งดนตร ี
สิง่ของทีจั่บตอ้งไมไ่ด ้เชน่ หลกัสตูร วชิา เพลง การประชมุ ซอฟตแ์วร ์
14
![Page 15: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/15.jpg)
ตัวอยา่ง
15
![Page 16: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/16.jpg)
การเขยีนสญัลักษณ ์
กรณีไมม่aีttributeอืน่
กรณีมแีต ่primary key
กรณีมaีttribute
Entity name
16
![Page 17: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/17.jpg)
ตวัอยา่ง
การประชมุ
ลกูคา้
วชิา
นักศกึษา
การตัง้ชือ่เป็นค านามที่กระชบัและชดัเจน
17
![Page 18: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/18.jpg)
ขอ้ควรระวงั
ใน ERD หนึง่ๆ จะม ีentity ชือ่ซ ้ากนัไมไ่ด ้
ชือ่ภาษาองักฤษไมจ่ าเป็นตอ้งเป็นพหพูจนถ์งึแมจ้ะหมายถงึสิง่ของจ านวนหลายชิน้
ชือ่ทีต่ัง้สามารถเขา้ใจไดอ้ยา่งชดัเจนวา่ขอ้มลูทีเ่ก็บคอือะไร
ชือ่ตอ้งกระชบั ไมย่าวเยิน่เยอ้ เชน่ ไมใ่ช ่“ลกูคา้ของบรษัิท” ควรใช ้“ลกูคา้”
18
![Page 19: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/19.jpg)
ประเภทของ Entity
Strong entity type
ไมข่ึน้กบัขอ้มลูอืน่
ขอ้มลูสว่นใหญจั่ดอยูใ่นประเภทนี ้
19
![Page 20: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/20.jpg)
Weak entity type
เป็นขอ้มลูทีม่ลีกัษณะขึน้กบัขอ้มลูอืน่ (Existence
dependent)
ขอ้มลูใน Weak entity มทีีม่าจากจาก Entity อืน่เป็นหลกัจงึ
ตอ้งพึง่พงิกบัขอ้มลูเหลา่นัน้ หากขอ้มลูหลกัถกูลบทิง้หรอื
เปลีย่นแปลง จะสง่ผลกระทบตอ่ขอ้มลูใน Weak entity
การออกแบบทีร่ะบวุา่ขอ้มลูนัน้มคีณุสมบตัทิีพ่ ึง่พงิเมือ่สรา้ง
ฐานขอ้มลูขึน้มาจะตอ้งเขยีนค าสัง่ DDL ทีก่ าหนดความผกูพัน
นีไ้วด้ว้ย
20
![Page 21: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/21.jpg)
ตวัอยา่งความสมัพันธร์ะหวา่ง Weak และ Strong entity type
อาจารยเ์ป็น Strong entity type แตป่ระวตักิารศกึษา(ของอาจารย)์ เป็น Weak entity type
Ph.D. (Computer science) UNSW
M.Sc. (Applied Statistics) NIDA
B.Sc. (Mathematics) PSU
สมศร ีสอนนาน สารสนเทศศาสตร ์4555 วชิาการ12 111
21
![Page 22: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/22.jpg)
ตวัอยา่ง Strong และ Weak entity
เลขที ่111 15 เมษายน 2552
ใบส ัง่ซือ้สนิคา้
เรยีน บรษัิท คนกนัเอง จ ากดั
รวมทัง้ส ิน้ 12,000 บาท
ขอสัง่ซือ้สนิคา้ดงัรายการตอ่ไปนี ้
รายการ จ านวน ราคาตอ่หน่วย รวม(บาท)
1. แชมพ ู 50 100 5000 2. สบู ่ 100 20 2000 3. ยาสฟัีน 100 50 5000
22
![Page 23: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/23.jpg)
ใบสัง่ซือ้เป็น Strong entity type แตร่ายละเอยีดการสัง่ซือ้(ของใบสัง่ซือ้นัน้) เป็น Weak entity type
เลขที ่111 15 เมษายน 2552
ใบส ัง่ซือ้สนิคา้
บรษัิท คนกนัเอง จ ากดั ยอดรวม 12,000 บาท
รายละเอยีดของใบสัง่ซือ้ 1. แชมพ ู 50 ขวดๆละ 100 บาท 2. สบู ่ 100 กอ้นๆละ 20 บาท 3. ยาสฟัีน 100 หลอดๆละ 50 บาท
23
![Page 24: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/24.jpg)
ตวัอยา่ง
24
![Page 25: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/25.jpg)
ตวัอยา่ง
ผูป่้วย
รหสั {pk} ชือ่ นามสกลุ เพศ วดปเกดิ
ประวัตอิาการ ครัง้ที ่วันที ่BT BW BP อาการ
ม ี
25
![Page 26: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/26.jpg)
Relationship Types
Relationship type
Set of meaningful associations among entity types.
Relationship occurrence
Uniquely identifiable association, which includes one occurrence from each participating entity type.
26
![Page 27: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/27.jpg)
ตัวอยา่ง
meaningful associations
27
![Page 28: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/28.jpg)
Semantic net of Has relationship type
Relationship occurrence คอื r1 (B003, SG37), r2 และ r3
28
![Page 29: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/29.jpg)
Degree of a relationship
Number of participating entities in relationship.
Relationship of degree :
two is binary
three is ternary
four is quaternary.
29
![Page 30: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/30.jpg)
สญัลักษณท์ีใ่ช ้
หากเป็นการเชือ่มโยงใน entity เดยีวหรอืระหวา่ง 2 entity ใช ้
เสน้ตรง ทีเ่ป็นเสน้ทบึ
หากม ีentity ตัง้แต ่3 ขึน้ไปจะเพิม่สีเ่หลีย่มขนมเปียกปนู
student course enroll
doctor medicine
patient
prescribe
30
![Page 31: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/31.jpg)
1. พจิารณาตามจ านวนของสมาชกิของ entity ทีเ่กีย่วขอ้งกนั
1:1 relationship
1:N และ N:1 relationship
N:N relationship
2. พจิารณาตามจ านวนของ entity ทีเ่กีย่วขอ้ง
Binary relationship
Unary relationship
Ternary relationship
N-ary relationship
Connection Relationship และ การจัดประเภทของ Relationship
31
![Page 32: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/32.jpg)
3. พจิารณาตามเงือ่นไขการมสีว่นรว่มของความสมัพันธ ์
Mandatory participation
Optional participation
4. พจิารณาจากประเภทของ entity ทีน่ ามาเชือ่มโยงกรณีม ีweak entity type มาเกีย่วขอ้ง
Existence dependency
Identifier dependency
32
![Page 33: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/33.jpg)
Binary relationship called POwns
student course enroll
lecturer course teach
33
![Page 34: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/34.jpg)
Ternary relationship called Registers
doctor medicine
patient
prescribe
Doctor prescribes some medicine for his patient
34
![Page 35: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/35.jpg)
Quaternary relationship called “Arranges”
35
![Page 36: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/36.jpg)
Recursive Relationship
Relationship type where same entity type participates more than once in different roles.
Relationships may be given role names to indicate purpose that each participating entity type plays in a relationship.
ความสมัพันธใ์น entity เดยีว
36
![Page 37: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/37.jpg)
Recursive relationship called Supervises with role names
37
![Page 38: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/38.jpg)
Recursive relationship
subject subject is prerequisite of
เชน่ MIT-532 เป็นวชิาบงัคบัเรยีนกอ่นของวชิา MIT-533
subject
is prerequisite of
38
![Page 39: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/39.jpg)
Entities associated through two distinct relationships with role names
39
![Page 40: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/40.jpg)
Attributes
Property of an entity or a relationship type.
เพลง
ชือ่เพลง
ผูแ้ตง่เนือ้เพลง
ผูแ้ตง่ท านอง
ผูร้อ้ง
ความยาวของเพลง
40
![Page 41: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/41.jpg)
Attributes ของ relationship
41
![Page 42: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/42.jpg)
ตวัอยา่ง
teach
term year percent-resps
Lecturer ID {pk} Title Name Phone office
Course ID {pk} Title Credit
42
![Page 43: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/43.jpg)
Entity and attribute
หากสงัเกตใหด้จีะเห็นวา่เมือ่กลา่วถงึ นักศกึษา ยานพาหนะ หรอื สนิคา้ เป็นการกลา่วถงึ นักศกึษาโดยรวม ยานพาหนะโดยรวม และ สนิคา้โดยรวม
มรีายละเอยีดตามทีร่ะบโุดย Attribute
ไมไ่ดเ้จาะจงเป็นนักศกึษาเฉพาะคน สนิคา้เฉพาะรายการ หรอืยานพาหนะเฉพาะคนั
43
![Page 44: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/44.jpg)
entity/attribute ไมใ่ช ่Data value
อาหาร
ชือ่อาหาร (เชน่กว๋ยเตีย๋วหมสูบั ซปุขา้วโพด ซา่หริม่ ขา้วซอย ขนมปังหนา้กุง้)
ประเภท (เชน่ของคาว ของหวาน ของวา่ง)
จ านวนแคลอร ี
ราคาอาหาร
44
![Page 45: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/45.jpg)
Domain ของ Attribute
Set of allowable values for one or more attributes.
ทกุแอทรบิวิทจ์ะตอ้งมโีดเมน
แอทรบิวิทม์ากกวา่ 1 แอทรบิวิท ์สามารถใชโ้ดเมนเดยีวกนั
วนัที ่(คอื dd/mm/yy) เป็นโดเมนของ
วนัเกดิ
วนัเริม่งาน
วนัยืน่ใบสมคัร
วนัทีล่าออก
45
![Page 46: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/46.jpg)
โดเมนสามารถระบเุป็นชว่ง (Range) ได ้เชน่ คา่ของระดบัชัน้ของขา้ราชการหรอื C ตัง้แต ่1 ถงึ 11
โดเมนสามารถก าหนดเป็นคา่จ าเพาะได ้เชน่ คา่ของ gender หรอืเพศ ม ี2 คา่คอื “ช” หรอื “ญ” เทา่นัน้
46
![Page 47: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/47.jpg)
โดเมนอาจประกอบดว้ยโดเมนยอ่ย เชน่ วนัทีป่ระกอบดว้ย วนั เดอืน และ ปี หากพจิารณาแตล่ะสว่น
วนัมคีา่ทีใ่ชไ้ดอ้ยูใ่นชว่ง 1 ถงึ 31 หรอื เดอืนมคีา่ทีใ่ชไ้ดอ้ยู่ระหวา่ง 1 ถงึ 12 เป็นตน้
Date day
month
year
47
![Page 48: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/48.jpg)
ในการก าหนดโดเมนใหก้บัแอทรบิวิทบ์างแอทรบิวิท ์อาจมีเกณฑใ์หเ้ลอืกใชห้ลายแบบ
เชน่ สว่นสงูของคนอาจมหีน่วยเป็นเซนตเิมตร หรอื เป็นฟตุกไ็ด ้
จงึตอ้งเลอืกวา่จะเก็บแบบไหน เพราะคา่ทีเ่ก็บจะตา่งกนั
48
![Page 49: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/49.jpg)
ประโยชนข์องโดเมน
ใชเ้พือ่ก าหนดวา่การท างานใดจะใชก้บัขอ้มลูนัน้ได ้เชน่ถา้ขอ้มลูเป็นตวัเลขจงึจะบวกกนัได ้
ใชเ้พือ่ก าหนดวา่สามารถน าแอทรบิวิทใ์ดมาเปรยีบเทยีบกนัไดบ้า้ง
ใชเ้พือ่ตรวจสอบวา่คา่ทีเ่ป็นไปไดข้องแอทรบิวิทน์ีเ้ป็นคา่ใด
ใชเ้พือ่ก าหนดเนือ้ทีแ่ละรปูแบบทีใ่ชไ้ดก้บัขอ้มลูนัน้ๆเมือ่จะสรา้งตารางจรงิๆ
49
![Page 50: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/50.jpg)
ประเภทของ Attributes
Simple Attribute
เป็นแอทรบิวิทท์ีไ่มส่ามารถแบง่ยอ่ยออกเป็นแอทรบิวิทไ์ด ้อกี
เชน่ เพศ ชือ่ภาควชิา ถนน เงนิเดอืน รหสันักศกึษา รหสัวชิา จ านวนหน่วยกติ ยีห่อ้สนิคา้ จ านวนทีส่ัง่ซือ้
50
![Page 51: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/51.jpg)
Composite Attribute
Attribute composed of multiple components, each with an independent existence.
เกดิจากแอทรบิวิทย์อ่ยๆมารวมกนั หรอืสามารถทีจ่ะแบง่ออกมาเป็นสว่นยอ่ยได ้
โดยทัว่ไปมกัใชใ้นระดบัการออกแบบเพือ่ใหเ้ห็นภาพรวมเสยีกอ่นจากนัน้จงึพจิารณาวา่ตอ้งการเรยีกใชเ้ฉพาะสว่นใดสว่นหนึง่ของขอ้มลูหรอืไม ่
เชน่ทีอ่ยูป่ระกอบดว้ย บา้นเลขที ่ถนน หมูท่ี ่อ าเภอ จังหวดั รหสัไปรษณีย ์
51
![Page 52: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/52.jpg)
Single-valued Attribute
Attribute that holds a single value for each occurrence of an entity type.
โดยทัว่ไปแลว้แอทรบิวิทม์กัเป็นประเภทนี ้
กลุม่เลอืด (เชน่มคีา่เป็น A, B, AB หรอื O เพยีงคา่เดยีว)
จ านวนหน่วยกติของรายวชิา (เชน่มคีา่เป็น 1, 2, 3 หรอื 6 เพยีงคา่เดยีว)
ชือ่นักศกึษา
หมายเลขหอ้งเรยีน
52
![Page 53: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/53.jpg)
Multi-valued Attribute
Attribute that holds multiple values for each occurrence of an entity type.
ในบางกรณีการเก็บขอ้มลูอาจพบวา่คา่ทีต่อ้งการเก็บของแอทริบวิทนั์น้มคีา่มากกวา่ 1 คา่ เชน่ หมายเลขโทรศพัทข์องลกูคา้อาจมมีากกวา่ 1 หมายเลข หรอื e-mail ทีใ่ชต้ดิตอ่อาจมีมากกวา่ 1
กรณีนีใ้นการออกแบบใหใ้ชส้ญัลกัษณ์พเิศษเพือ่เป็นการเตอืนผูอ้อกแบบวา่จะตอ้งด าเนนิการแกไ้ขใหเ้หลอืเพยีงคา่เดยีวในขัน้ตอนตอ่ๆไป
53
![Page 54: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/54.jpg)
Derived Attribute
Attribute that represents a value that is derivable from value of a related attribute, or set of attributes, not necessarily in the same entity type.
คา่ของ attribute สามารถหามา หรอื ค านวณไดจ้าก attribute อืน่โดยไมต่อ้งใสค่า่ลงไปเองโดยผูใ้ช ้
ในการเก็บคา่บางประเภทเชน่ อาย ุจัดไดว้า่เป็นคา่ทีแ่ปรไปตามวนัเวลาทีเ่ปลีย่นไป (เพิม่ขึน้ตามกาลเวลา) ดงันัน้เมือ่เรยีกใชแ้ตล่ะครัง้อายจุงึตอ้งมกีารค านวณเพือ่แสดงอายทุี่ถกูตอ้ง
54
![Page 55: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/55.jpg)
ตวัอยา่งและสญัลักษณท์ีใ่ช ้
55
![Page 56: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/56.jpg)
Keys
Candidate Key
Minimal set of attributes that uniquely identifies each occurrence of an entity type.
Primary Key
Candidate key selected to uniquely identify each occurrence of an entity type.
Composite Key
A candidate key that consists of two or more attributes.
56
![Page 57: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/57.jpg)
Main type of constraint on relationships is called multiplicity.
Multiplicity - number (or range) of possible occurrences of an entity type that may relate to a single occurrence of an associated entity type through a particular relationship.
Represents policies (called business rules) established by user or company.
Structural Constraints
57
![Page 58: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/58.jpg)
The most common degree for relationships is binary.
Binary relationships are generally referred to as being:
one-to-one (1:1)
one-to-many (1:*)
many-to-many (*:*)
58
![Page 59: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/59.jpg)
เงือ่นไขการระบคุวามสมัพันธ ์
เงือ่นไขของการเขยีน (min, max)
student ใช ้(1,*) และ course ใช ้(0,*)
ความหมายคอื นักศกึษาแตล่ะคนสามารถลงทะเบยีนไดห้ลายวชิา และตอ้งเรยีนอยา่งนอ้ย 1 วชิา ในขณะทีว่ชิาหนึง่ๆอาจมนัีกศกึษาเรยีนมากกวา่ 1 คน แตบ่างวชิาอาจไมม่นัีกศกึษาเรยีนเลย
student course enroll (1,*) (0,*)
59
![Page 60: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/60.jpg)
Semantic net of Staff Manages Branch relationship type
60
![Page 61: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/61.jpg)
Multiplicity of Staff Manages Branch (1:1) relationship
61
![Page 62: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/62.jpg)
Semantic net of Staff Oversees PropertyForRent relationship type
62
![Page 63: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/63.jpg)
Multiplicity of Staff Oversees PropertyForRent (1:*) relationship type
63
![Page 64: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/64.jpg)
Semantic net of Newspaper Advertises PropertyForRent relationship type
64
![Page 65: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/65.jpg)
Multiplicity of Newspaper Advertises PropertyForRent (*:*) relationship
65
![Page 66: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/66.jpg)
Structural Constraints
Multiplicity for Complex Relationships
Number (or range) of possible occurrences of an entity type in an n-ary relationship when other (n-1) values are fixed.
66
![Page 67: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/67.jpg)
Semantic net of ternary Registers relationship with values for Staff and Branch entities fixed
67
![Page 68: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/68.jpg)
Multiplicity of ternary Registers relationship
68
![Page 69: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/69.jpg)
Summary of multiplicity constraints
69
![Page 70: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/70.jpg)
Structural Constraints
Multiplicity is made up of two types of restrictions on relationships:
Cardinality
Describes maximum number of possible relationship occurrences for an entity participating in a given relationship type.
Participation
Determines whether all or only some entity occurrences participate in a relationship.
70
![Page 71: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/71.jpg)
Multiplicity as cardinality and participation constraints
71
![Page 72: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/72.jpg)
Problems with ER Models
Problems may arise when designing a conceptual data model called connection traps.
Often due to a misinterpretation of the meaning of certain relationships.
Two main types of connection traps are called fan traps and chasm traps.
72
![Page 73: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/73.jpg)
Problems with ER Models
Fan Trap
Where a model represents a relationship between entity types, but pathway between certain entity occurrences is ambiguous.
Chasm Trap
Where a model suggests the existence of a relationship between entity types, but pathway does not exist between certain entity occurrences.
73
![Page 74: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/74.jpg)
An Example of a Fan Trap
74
![Page 75: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/75.jpg)
Semantic Net of ER Model with Fan Trap
At which branch office does staff number SG37
work?
75
![Page 76: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/76.jpg)
Restructuring ER model to remove Fan Trap
76
![Page 77: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/77.jpg)
Semantic Net of Restructured ER Model with Fan Trap Removed
SG37 works at branch B003.
77
![Page 78: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/78.jpg)
An Example of a Chasm Trap
78
![Page 79: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/79.jpg)
Semantic Net of ER Model with Chasm Trap
At which branch office is property PA14 available?
79
![Page 80: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/80.jpg)
ER Model restructured to remove Chasm Trap
80
![Page 81: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/81.jpg)
Semantic Net of Restructured ER Model with Chasm Trap Removed
81
![Page 82: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/82.jpg)
82
Enhanced entity-relationship modeling
![Page 83: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/83.jpg)
Objectives
Limitations of basic concepts of the ER model and requirements to represent more complex applications using additional data modeling concepts.
Most useful additional data modeling concept of Enhanced ER (EER) model is called specialization/generalization.
A diagrammatic technique for displaying specialization/generalization in an EER diagram using UML.
83
![Page 84: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/84.jpg)
Enhanced Entity-Relationship Model
Since 1980s there has been an increase in emergence of new database applications with more demanding requirements.
Basic concepts of ER modeling are not sufficient to represent requirements of newer, more complex applications.
Response is development of additional ‘semantic’ modeling concepts.
84
![Page 85: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/85.jpg)
The Enhanced Entity-Relationship Model
Semantic concepts are incorporated into the original ER model and called the EER model.
Examples of additional concept of EER model is called specialization / generalization.
85
![Page 86: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/86.jpg)
Specialization / Generalization
Superclass
An entity type that includes one or more distinct subgroupings of its occurrences.
Subclass
A distinct subgrouping of occurrences of an entity type.
86
![Page 87: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/87.jpg)
Specialization / Generalization
Superclass/subclass relationship is one-to-one (1:1).
Superclass may contain overlapping or distinct subclasses.
Not all members of a superclass need be a member of a subclass.
87
![Page 88: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/88.jpg)
Specialization / Generalization
Attribute Inheritance
An entity in a subclass represents same ‘real world’ object as in superclass, and may possess subclass-specific attributes, as well as those associated with the superclass.
88
![Page 89: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/89.jpg)
Specialization / Generalization
Specialization
Process of maximizing differences between members of an entity by identifying their distinguishing characteristics.
Generalization
Process of minimizing differences between entities by identifying their common characteristics.
89
![Page 90: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/90.jpg)
AllStaff relation holding details of all staff
90
![Page 91: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/91.jpg)
Specialization/generalization
91
![Page 92: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/92.jpg)
Specialization/generalization
92
![Page 93: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/93.jpg)
Shared subclass and subclass with its own subclass
93
![Page 94: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/94.jpg)
Constraints on Specialization / Generalization
Two constraints that may apply to a specialization/generalization:
participation constraints
disjoint constraints.
Participation constraint
Determines whether every member in superclass must participate as a member of a subclass.
May be mandatory or optional.
94
![Page 95: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/95.jpg)
Constraints on Specialization / Generalization
Disjoint constraint
Describes relationship between members of the subclasses and indicates whether member of a superclass can be a member of one, or more than one, subclass.
May be disjoint or nondisjoint.
95
![Page 96: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/96.jpg)
Constraints on Specialization / Generalization
There are four categories of constraints of specialization and generalization:
mandatory and disjoint
optional and disjoint
mandatory and nondisjoint
optional and nondisjoint.
96
![Page 97: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/97.jpg)
Staff Superclass with subclasses
97
![Page 98: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/98.jpg)
Owner Superclass with subclasses
98
![Page 99: Entity-relationship modeling - Walailak Universitymit.wu.ac.th/mit/images/editor/files/DBS 2556 2--ER... · 2013. 10. 21. · How to use Entity–Relationship (ER) modeling in database](https://reader036.vdocuments.us/reader036/viewer/2022071515/6137f8e50ad5d2067648f887/html5/thumbnails/99.jpg)
Person superclass with subclasses
99