Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of...

22
1 Chapter 4 © 2005 by Prentice Hall © 2005 by Prentice Hall Objectives Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype relationships Use of generalization and specialization Use of generalization and specialization techniques techniques Specification of completeness and Specification of completeness and disjointness constraings disjointness constraings Develop supertype/subtype hierarchies for Develop supertype/subtype hierarchies for common business situations common business situations Develop entity clusters Develop entity clusters Name categories of business rules Name categories of business rules Define operational constraints graphically Define operational constraints graphically and in English and in English
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    242
  • download

    3

Transcript of Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of...

Page 1: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

11Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

ObjectivesObjectives Definition of termsDefinition of terms Use of supertype/subtype relationshipsUse of supertype/subtype relationships Use of generalization and specialization Use of generalization and specialization

techniquestechniques Specification of completeness and disjointness Specification of completeness and disjointness

constraingsconstraings Develop supertype/subtype hierarchies for Develop supertype/subtype hierarchies for

common business situationscommon business situations Develop entity clustersDevelop entity clusters Name categories of business rulesName categories of business rules Define operational constraints graphically and in Define operational constraints graphically and in

EnglishEnglish

Page 2: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

22Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Supertypes and SubtypesSupertypes and Subtypes

Subtype:Subtype: A subgrouping of the entities in an A subgrouping of the entities in an entity type which has attributes that are entity type which has attributes that are distinct from those in other subgroupingsdistinct from those in other subgroupings

Supertype:Supertype: An generic entity type that has An generic entity type that has a relationship with one or more subtypesa relationship with one or more subtypes

Attribute Inheritance:Attribute Inheritance: Subtype entities inherit values of all Subtype entities inherit values of all

attributes of the supertypeattributes of the supertype An instance of a subtype is also an instance An instance of a subtype is also an instance

of the supertypeof the supertype

Page 3: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

33Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Page 4: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

44Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Different modeling tools may have different notation for the same modeling constructs

Page 5: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

55Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-2 – Employee supertype with three subtypes

All employee subtypes will have emp nbr, name, address, and date-hired

Each employee subtype will also have its own attributes

Page 6: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

66Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Relationships and SubtypesRelationships and Subtypes

Relationships at the Relationships at the supertypesupertype level level indicate that all subtypes will indicate that all subtypes will participate in the relationshipparticipate in the relationship

The instances of a The instances of a subtypesubtype may may participate in a relationship unique to participate in a relationship unique to that subtype. In this situation, the that subtype. In this situation, the relationship is shown at the subtype relationship is shown at the subtype levellevel

Page 7: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

77Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-3 – Supertype/subtype relationships in a hospital

Both outpatients and resident patients are cared for by a responsible physician

Only resident patients are assigned to a bed

Page 8: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

88Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Generalization and Generalization and SpecializationSpecialization

Generalization:Generalization: The process of The process of defining a more general entity type from defining a more general entity type from a set of more specialized entity types. a set of more specialized entity types. BOTTOM-UPBOTTOM-UP

Specialization:Specialization: The process of The process of defining one or more subtypes of the defining one or more subtypes of the supertype, and forming supertype, and forming supertype/subtype relationships. TOP-supertype/subtype relationships. TOP-DOWNDOWN

Page 9: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

99Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-4a – Example of generalization

Three entity types: CAR, TRUCK, and MOTORCYCLE

All these types of vehicles have common attributes

Page 10: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1010Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-4b – Generalization to VEHICLE supertype

So we put the shared attributes in a supertype

Note: no subtype for motorcycle, since it has no unique attributes

Page 11: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1111Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-5a – Example of specialization

Entity type PART

Only applies to manufactured

parts

Applies only to purchased parts

Page 12: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1212Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-5b – Specialization to MANUFACTURED PART and PURCHASED PART

Note: multivalued attribute was replaced by a relationship to another entity

Created 2 subtypes

Page 13: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1313Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Constraints in Supertype/ Constraints in Supertype/ Completeness ConstraintCompleteness Constraint

Completeness ConstraintsCompleteness Constraints: Whether : Whether an instance of a supertype an instance of a supertype mustmust also be a also be a member of at least one subtypemember of at least one subtype Total Specialization Rule: Yes (double line)Total Specialization Rule: Yes (double line) Partial Specialization Rule: No (single line)Partial Specialization Rule: No (single line)

Page 14: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1414Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-6a – Examples of completeness constraints

Total specialization rule

A patient must be either an outpatient or a resident patient

Page 15: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1515Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-6b – Partial specialization rule

A vehicle could be a car, a truck, or neither

Page 16: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1616Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Constraints in Supertype/ Constraints in Supertype/ Disjointness constraintDisjointness constraint

Disjointness ConstraintsDisjointness Constraints: : Whether an instance of a supertype may Whether an instance of a supertype may simultaneouslysimultaneously be a member of two (or be a member of two (or more) subtypesmore) subtypes Disjoint Rule: An instance of the supertype Disjoint Rule: An instance of the supertype

can be only ONE of the subtypescan be only ONE of the subtypes Overlap Rule: An instance of the supertype Overlap Rule: An instance of the supertype

could be more than one of the subtypescould be more than one of the subtypes

Page 17: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1717Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Disjoint rule

Figure 4-7a – Examples of disjointness constraints

A patient can either be outpatient or resident, but not both

Page 18: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1818Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-7b Overlap rule

A part may be both purchased and manufactured

Page 19: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

1919Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Constraints in Supertype/ Constraints in Supertype/ Subtype DiscriminatorsSubtype Discriminators

Subtype DiscriminatorSubtype Discriminator: An attribute : An attribute of the supertype whose values determine of the supertype whose values determine the target subtype(s)the target subtype(s) DisjointDisjoint – a – a simplesimple attribute with alternative attribute with alternative

values to indicate the possible subtypesvalues to indicate the possible subtypes OverlappingOverlapping – a – a compositecomposite attribute whose attribute whose

subparts pertain to different subtypes. Each subparts pertain to different subtypes. Each subpart contains a boolean value to indicate subpart contains a boolean value to indicate whether or not the instance belongs to the whether or not the instance belongs to the associated subtypeassociated subtype

Page 20: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

2020Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-8 – Introducing a subtype discriminator (disjoint rule)

A simple attribute with different possible values indicating the subtype

Page 21: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

2121Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-9 – Subtype discriminator (overlap rule)

A composite attribute with sub-attributes indicating “yes” or “no” to determine whether it is of each subtype

Page 22: Chapter 4 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Use of supertype/subtype relationships Use of supertype/subtype.

2222Chapter 4 © 2005 by Prentice Hall© 2005 by Prentice Hall

Figure 4-17 – Data model segment for class scheduling