Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from...
-
Upload
bruce-griffin -
Category
Documents
-
view
214 -
download
1
Transcript of Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from...
![Page 1: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/1.jpg)
Extending ER Diagrams (13)
CPSC 356 Database
Ellen Walker
Hiram College
(Includes figures from Database Systems: A Practical Approach to Design, Information and Management, by Connolly and Begg, © Addison Wesley 2010)
![Page 2: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/2.jpg)
Basic ER Diagram Cannot Capture Specialization/ Generalization
• Examples– Doctors and Nurses are Medical Staff– Staff includes Medical staff, Secretarial staff,
Housekeeping staff, etc.
• Relationships might include Doctors, Medical Staff, and/or Staff
• ER diagram cannot represent the fact that Staff > Medical staff > doctors
• EER diagram can!
![Page 3: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/3.jpg)
Entity Type Hierarchies
• An entity type E1 is a subclass of the entity type E2 when– Every entity instance of E1 is also an instance of
E2– Every attribute in E2 is also in E1
• The opposite of a subclass is a superclass• Subclasses are related to superclasses
through the IS-A relationship
![Page 4: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/4.jpg)
When to Use?
• When you have an entity that needs to have extra / different attributes “sometimes”
• When you have two entities that overlap on many or most of their attributes
![Page 5: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/5.jpg)
Subclass / Superclass Example
• Doctor is a subclass of medical-staff• Staff is a superclass of medical-staff
• Attributes – Staff - name, addr, salary– Med-staff - pager #– Doctor - license #
Staff
Medical-Staff Admin-Staff
Doctor Nurse
![Page 6: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/6.jpg)
Attribute Inheritance
• Each entity type inherits all attributes of its superclass(es)– Staff has name, address, salary– Medical staff has {n,a,s} + beeper-number– Doctor has {n, a, s, b#} + license #
• In EER diagram, inherited attributes only appear once (in the highest superclass)
![Page 7: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/7.jpg)
Generalizing Type Hierarchies
• Multiple superclasses for the same subclass– A student-employee is both a student and an
employee
• Overlapping subclasses– Subclasses of person are student and employee– There is at least one individual who is both a
student and an employee
• Non-overlapping subclasses are called “disjoint”
![Page 8: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/8.jpg)
Specialization of Staff (13.2)
![Page 9: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/9.jpg)
Extended ER (EER) Diagram
• IS-A relationships• Notation for disjoint (vs. overlapping)
subclasses– Disjoint = “or”, overlapping = “and”
• Notation for “covering”– Can someone be staff without being Medical or
administrative?– If so, “optional”; if not “mandatory”
![Page 10: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/10.jpg)
More Staff Types (13.3)
![Page 11: Extending ER Diagrams (13) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: A Practical Approach to Design, Information.](https://reader036.fdocuments.us/reader036/viewer/2022082817/56649dd35503460f94acaa05/html5/thumbnails/11.jpg)
Additional Semantic Relationships
• Aggregation and Composition– Collecting together related entities that represent ‘parts’ of a
‘whole’– Aggregation (non-exclusive subpart): parts can change parents– Composition (exclusive subpart): single parent, very strong
association - parts make no sense without parent– Examples:
• Branch (whole) has Staff (part) Aggregation
• Newspaper (whole) contains Story (part) Composition
• EER representation is diamond with arrow from “part”– Open for aggregation, closed for composition – (see 13.9, 13.10)