Extending ER Diagrams (13)Basic ER Diagram Cannot Capture Specialization/ GeneralizationEntity Type HierarchiesWhen to Use?Subclass / Superclass ExampleAttribute InheritanceGeneralizing Type HierarchiesSpecialization of Staff (13.2)Extended ER (EER) DiagramMore Staff Types (13.3)Additional Semantic RelationshipsExtending ER Diagrams (13)CPSC 356 DatabaseEllen WalkerHiram College(Includes figures from Database Systems: A Practical Approach to Design, Information and Management, by Connolly and Begg, © Addison Wesley 2010)Basic ER Diagram Cannot Capture Specialization/ Generalization•Examples–Doctors and Nurses are Medical Staf–Staf includes Medical staf, Secretarial staf, Housekeeping staf, etc.•Relationships might include Doctors, Medical Staf, and/or Staf•ER diagram cannot represent the fact that Staf > Medical staf > doctors•EER diagram can!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 relationshipWhen to Use?•When you have an entity that needs to have extra / diferent attributes “sometimes”•When you have two entities that overlap on many or most of their attributesSubclass / Superclass Example•Doctor is a subclass of medical-staf•Staf is a superclass of medical-staf•Attributes –Staf - name, addr, salary–Med-staf - pager #–Doctor - license #StafMedical-Staf Admin-StafDoctor NurseAttribute Inheritance•Each entity type inherits all attributes of its superclass(es)–Staf has name, address, salary–Medical staf 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)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”Specialization of Staf (13.2)Extended ER (EER) Diagram•IS-A relationships•Notation for disjoint (vs. overlapping) subclasses–Disjoint = “or”, overlapping = “and”•Notation for “covering”–Can someone be staf without being Medical or administrative?–If so, “optional”; if not “mandatory”More Staf Types (13.3)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 Staf (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,
View Full Document