Upload
lorin-jordan
View
217
Download
0
Embed Size (px)
DESCRIPTION
Slide 4-3 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Revised by IB & SAM, Fasilkom UI, 2005 Outline Superclass/Subclass Relationship Specialization/Generalization Type Inheritance/Constraints/Updates Categorization Higher-Degree Relationships
Citation preview
Slide 4-1 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Exercise1. a property or description of an entity 2. a set of possible values for an attribute.3. an object in the real world that is distinguishable
from other objects such as the green dragon toy.4. an association among two or more entities.5. a collection of similar entities such as all of the
toys in the toy department.6. a collection of similar relationships7. a key constraint that indicates that one entity
can be associated with many of another entity. 8. a key constraint that indicates that many of one
entity can be associated with many of another entity.
9. an entity that cannot be identified uniquely without considering some primary key attributes of another identifying owner entity.
10. maximum number of instances of an entity that can participate in an instance of a relationship
11. is the least number of instances of an entity that can participate in an instance of a relationship
a. Domainb. Entityc. Relationshipd. Entity sete. One-to-many
relationshipf. Relationship setg. Attributeh. Minimum
cardinalityi. Weak entityj. Maximum
cardinalityk. Many-to-many
relationship
2
Enhanced/Extended Relationship-Diagram
The main reference of this presentation is the textbook and PPT from : Elmasri & Navathe, Fundamental of Database Systems, 4th edition, 2004, Chapter 4Additional resources: presentation prepared by Prof Steven A. Demurjian, Sr (http://www.engr.uconn.edu/~steve/courses.html)
Slide 4-3 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
OutlineSuperclass/Subclass RelationshipSpecialization/GeneralizationType Inheritance/Constraints/UpdatesCategorizationHigher-Degree Relationships
Slide 4-4 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Enhanced-ER (EER) Model Concepts
Includes all modeling concepts of basic ER Additional concepts: subclasses/superclasses, specialization/generalization, categories, attribute inheritanceThe resulting model is called the enhanced-ER or Extended ER (E2R or EER) modelIt is used to model applications more completely and accurately if neededIt includes some object-oriented concepts, such as inheritance
Slide 4-5 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
SubclassEntity type describes:
Type of entityThe entity set
Example: ‘EMPLOYEE’Employee can be sub-grouped into:
SecretaryEngineerTechnicianManager
These are called the subclass of EMPLOYEE entity type.
Slide 4-6 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Super-classEMPLOYEE entity type is the super class of engineer, secretary & technician class.Subclass represent the same mini-world entity of the superclass, but in a distinct specific role.Entity in a subclass must be a member of a superclass, but not vice-versa! Example…?
Slide 4-7 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
SuperClass/SubClass Relationship
Superclass/subclass relationship is the relationship between a superclass and any one of its subclass or it simply class/subclass relationship
Employee/Secretary, Employee/Technician
These are also called IS-A relationships (SECRETARY IS-A EMPLOYEE, TECHNICIAN IS-A EMPLOYEE, …).
Slide 4-8 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Type inheritanceAn entity that is member of a subclass inherits all attributes of the entity as a member of the superclass It also inherits all relationships
Slide 4-9 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
SpecializationIs a process of defining a set of subclasses of an entity type (the superclass)On the basis of some distinguishing characteristic of the entity in the superclassMay have several specialization based on different characteristicsSECRETARY, ENGINEERS, & TECHNICIAN are specialization of EMPLOYEE based on job type attributeSALARIED_EMPLOYEE, HOURLY_EMPLOYEE are specialization of EMPLOYEE based on the method of pay
Slide 4-10 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Fig 4.2
Slide 4-11 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Notations from the EER diagram
Subset symbol ⊂Specific attributes, or local attributesSpecific relationshipsclass/subclass EMPLOYEE/SECRETARY resembles 1:1 relationship at the instance level, of one entity. playing a specialized role, an EMPLOYEE specialized the role of SECRETARY
Slide 4-12 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Benefit of SpecializationDefine a set of subclasses of an entity typeEstablish additional specific attributes with each subclassEstablish additional specific relationship types between each subclass and other entity types or other subclassesRefer to the EER diagram…!
Slide 4-13 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Fig 4.1
Slide 4-14 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
GeneralizationIdentify common features (attributes), and generalize into a superclassExample: truck & car can be generalized into VEHICLEInverse of the specialization process
Slide 4-15 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Slide 4-16 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Generalization and Specialization
Diagrammatic notation sometimes used to distinguish between generalization and specialization
Arrow pointing to the generalized superclass represents a generalization Arrows pointing to the specialized subclasses represent a specialization We do not use this notation because it is often subjective as to which process is more appropriate for a particular situation We advocate not drawing any arrows in these situations
Data Modeling with Specialization and GeneralizationA superclass or subclass represents a set of entities Shown in rectangles in EER diagrams (as are entity types) Sometimes, all entity sets are simply called classes, whether they are entity types, superclasses, or subclasses
Slide 4-17 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Constraints for Specialization and Generalization
Attribute-defined specialization• Base on values of a superclass attribute
(defining attribute)• All subclasses have their member condition
on the same attribute of the superclass• Predicate-defined (condition defined)
subclass• JobType = ‘Engineer’ => defining predicate
• User-defined Subclass• Each membership is determined by the user
Slide 4-18 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Constraints for Specialization and Generalization
Defining attribute
Predicate condition
Predicate-definedsubclass
Slide 4-19 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Constraints on Specialization and Generalization
Two other conditions apply to a specialization/generalization:Disjointness Constraint:
Specifies that the subclasses of the specialization must be disjointed (an entity can be a member of at most one of the subclasses of the specialization) Specified by d in EER diagram If not disjointed, overlap; that is the same entity may be a member of more than one subclass of the specialization Specified by o in EER diagram
Completeness Constraint: Total specifies that every entity in the superclass must be a member of some subclass in the specialization/ generalization Shown in EER diagrams by a double line Partial allows an entity not to belong to any of the subclasses Shown in EER diagrams by a single line
Slide 4-20 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Constraints on Specialization and Generalization (2)
Hence, we have four types of specialization/generalization:
Disjoint, total Disjoint, partial Overlapping, total Overlapping, partial
Note: Generalization usually is total because the superclass is derived from the subclasses.
Slide 4-21 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Disjointness constraintsSubclasses of a specialization must be disjointAn entity can only be at most one of the subclassLook at the previous EER diagramUse (d)
Slide 4-22 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
OverlapThe same entity may be a member of more than one subclass of the specializationUse the (o)Example, a person can be:
A studentA faculty memberAn alumni
Slide 4-23 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Slide 4-24 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Completeness constraintsTotal specialization:
Every entity in the superclass must be a member of some subclassExample, the Salaried_Employee and Hourly_EmployeeShown using double line
Slide 4-25 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Partial specialization:Allows an entity not to belong to any subclassExample: • Manager• Job type
Use single line
Slide 4-26 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
RulesDeleting entity from a superclass deletes it also from the subclassesInserting in a superclass, when attribute defined is filled must insert to the proper subclass as wellInserting in superclass of total specialization must insert into at least one subclass
Slide 4-27 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Hierarchy & LatticeHierarchy: a subclass only participates in one class/subclass relationshipExample: Vehicle with Car and TrucksLattice: a subclass can participate in more than one class/subclass relationshipExample: an Engineering Manager, must be an Engineer, and also a Manager!The concept of multiple inheritance
Slide 4-28 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Slide 4-29 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Figure 4.7
Slide 4-30 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
More Explanation of the EER Diagram
Leaf node: class that has no subclassesAn entity may exist in several leaves
Example, a student as Graduate_Student and a Teaching_Assistant
Multiple inheritance:Student_assistantBut the ‘Person’ attribute is only inherited once
Slide 4-31 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
UNION Types Using Categories
Engineering_Manager has 3 distinct relation, each relation has 1 superclassIn our new case, a subclass has a single relationship with 3 distinct superclass.The subclass represent collection of objects, which we call union type or category
Slide 4-32 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Figure 4.8
Slide 4-33 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
ExplanationA category OWNER is a union subclass of COMPANY, BANK and PERSONUse the (U) symbolRegistered_Vehicle is a union subclass of Car & Truck
Slide 4-34 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
The difference?Engineering_Manager must exist in all three superclass: Manager, Engineer, Salaried_EmployeeOwner, must exist in only one superclassesEngineering_Manager: inherited all superclasses attributesOwner, selective attribute inheritance, depending on the superclass
Slide 4-35 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Partial Category
Partial category, may or may not participate in the relation
Slide 4-36 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Total Category
Must be one of the superclassesExample: A building and a lot must be a member of PROPERTYMay be represented as a generalization (d), especially when the similarity is numerous
Slide 4-37 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Fig 4.10
Slide 4-38 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Higher Degree RelationshipTernary Relationship Type• relates three entity types (fig4.11a, fig3.10)• SUPPLY (SUPPLIER:PART:PROJECT)Three Binary Relationships• meaning is different! (fig4.11b, fig4.14)• CAN_SUPPLY (SUPPLIER:PART)• SUPPLIES (SUPPLIER:PROJECT)• USES (PROJECT:PART)
Slide 4-39 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Figure 4.11.a. Ternary Relationship
Slide 4-40 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Figure 4.11.b. Three binary relationship
Slide 4-41 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Ternary Relationship as Weak Entity Type• represents a ternary relationship type as a
weak entity type relating to the owner entity types (fig4.11c)
• includes binary (identifying) relationship types As an Identifying Relationship Type• a ternary relationship type with a weak entity
type and two owner entity types (fig4.13)
Higher Degree Relationship
Slide 4-42 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Ternary relationship as weak entity type
Slide 4-43 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Ternary Relationship as Identifying Relationship Type
Slide 4-44 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Another example of ternary versus binary relationship types. FIGURE
4.12
Slide 4-45 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
When to use EER model ?Most database projects do not need the object-oriented model features in EERGoal of conceptual data modeling is to produce a model that simple and easy to understandDo not use complicated class/subclass relationship if they are not neededOffer significant advantage over regular ER model
Slide 4-46 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
When to use EER model ?EER model is especially useful is domain being model is OO in nature and use inheritance reduce the complexity of the designCases using EER:
When using attribute inheritance can reduce the use of nulls in a single entity relation (that contains multiple subclasses)Subclasses can be used to explicitly model and name subsets of entity types that participate in their own relationships
Slide 4-47 Elmasri and Navathe, Fundamentals of Database Systems, Fourth EditionRevised by IB & SAM, Fasilkom UI, 2005
Alternative Diagrammatic Notations
Symbols for entity type / class, attribute and relationship
Displaying attributes
Displaying cardinality ratios
Various (min, max) notations
Notations for displaying specialization / generalization