Top Banner
1 Chapter 4: Chapter 4: The Enhanced ER Model The Enhanced ER Model and Business Rules and Business Rules Modern Database Management Modern Database Management 8 8 th th Edition Edition
35

1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

Dec 14, 2015

Download

Documents

Cameron Maudlin
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

11

Chapter 4:Chapter 4:The Enhanced ER Model The Enhanced ER Model

and Business Rulesand Business Rules

Modern Database Modern Database ManagementManagement

88thth Edition Edition

Page 2: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

22Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

ObjectivesObjectives Definition of termsDefinition of terms Use of supertype/subtype relationshipsUse of supertype/subtype relationships Use of generalization and specialization techniquesUse of generalization and specialization techniques Specification of completeness and disjointness Specification of completeness and disjointness

constraintsconstraints Develop supertype/subtype hierarchies for realistic Develop supertype/subtype hierarchies for realistic

business situationsbusiness situations Develop entity clustersDevelop entity clusters Explain universal data modelExplain universal data model Name categories of business rulesName categories of business rules Define operational constraints graphically and in Define operational constraints graphically and in

EnglishEnglish

Page 3: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

33Chapter 4 © 2007 by Prentice Hall© 2007 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 that has attributes distinct from entity type that has attributes distinct from those in other subgroupingsthose in other subgroupings

Supertype:Supertype: A generic entity type that has a A generic entity type that has a relationship with one or more subtypesrelationship 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 4: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

44Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-1 Basic notation for supertype/subtype notation

a) EER notation

Page 5: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

55Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

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

b) Microsoft

Visio Notation

Figure 4-1 Basic notation for supertype/subtype notation (cont.)

Page 6: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

66Chapter 4 © 2007 by Prentice Hall© 2007 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 7: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

77Chapter 4 © 2007 by Prentice Hall© 2007 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 8: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

88Chapter 4 © 2007 by Prentice Hall© 2007 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 9: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

99Chapter 4 © 2007 by Prentice Hall© 2007 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 10: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1010Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-4 Example of generalization

a) Three entity types: CAR, TRUCK, and MOTORCYCLE

All these types of vehicles have common attributes

Page 11: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1111Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-4 Example of generalization (cont.)

So we put the shared attributes in a supertype

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

b) Generalization to VEHICLE supertype

Page 12: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1212Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-5 Example of specialization

a) Entity type PART

Only applies to manufactured parts

Applies only to purchased parts

Page 13: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1313Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

b) Specialization to MANUFACTURED PART and PURCHASED PART

Note: multivalued attribute was replaced by an associative entity relationship to another entity

Created 2 subtypes

Figure 4-5 Example of specialization (cont.)

Page 14: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1414Chapter 4 © 2007 by Prentice Hall© 2007 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 15: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1515Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-6 Examples of completeness constraints

a) Total specialization rule

A patient must be either an outpatient or a resident patient

Page 16: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1616Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

b) Partial specialization rule

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

Figure 4-6 Examples of completeness constraints (cont.)

Page 17: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1717Chapter 4 © 2007 by Prentice Hall© 2007 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 18: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1818Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

a) Disjoint rule

Figure 4-7 Examples of disjointness constraints

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

Page 19: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

1919Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

b) Overlap rule

A part may be both purchased and manufactured

Figure 4-7 Examples of disjointness constraints (cont.)

Page 20: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2020Chapter 4 © 2007 by Prentice Hall© 2007 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 21: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2121Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

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

A simple attribute with different possible values indicating the subtype

Page 22: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2222Chapter 4 © 2007 by Prentice Hall© 2007 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 23: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2323Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-10 Example of supertype/subtype hierarchy

Page 24: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2424Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Entity ClustersEntity Clusters

EER diagrams are difficult to read when EER diagrams are difficult to read when there are too many entities and there are too many entities and relationshipsrelationships

Solution: Group entities and relationships Solution: Group entities and relationships into into entity clustersentity clusters

Entity clusterEntity cluster: Set of one or more entity : Set of one or more entity types and associated relationships types and associated relationships grouped into a single abstract entity typegrouped into a single abstract entity type

Page 25: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2525Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-13a Possible entity clusters for Pine Valley Furniture in Microsoft Visio

Related groups of entities could become clusters

Page 26: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2626Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-13b EER diagram of PVF entity clusters

More readable, isn’t it?

Page 27: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2727Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-14 Manufacturing entity cluster

Detail for a single cluster

Page 28: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2828Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Packaged data models provide generic models that can be customized for a particular organization’s business rules

Page 29: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

2929Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Business rulesBusiness rules

Statements that Statements that definedefine or or constrainconstrain some some aspect of the businessaspect of the business

Classification of business rules:Classification of business rules: Derivation–rule derived from other knowledge, often Derivation–rule derived from other knowledge, often

in the form of a formula using attribute valuesin the form of a formula using attribute values Structural assertion–rule expressing static structure. Structural assertion–rule expressing static structure.

Includes attributes, relationships, and definitionsIncludes attributes, relationships, and definitions Action assertion–rule expressing constraints/control Action assertion–rule expressing constraints/control

of organizational actionsof organizational actions

Page 30: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

3030Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-18EER diagram to describe business rules

Page 31: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

3131Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Types of Action AssertionsTypes of Action Assertions ResultResult

Condition–IF/THEN ruleCondition–IF/THEN rule Integrity constraint–must always be trueIntegrity constraint–must always be true Authorization–privilege statementAuthorization–privilege statement

FormForm Enabler–leads to creation of new objectEnabler–leads to creation of new object Timer–allows or disallows an actionTimer–allows or disallows an action Executive–executes one or more actionsExecutive–executes one or more actions

RigorRigor Controlling–something must or must not happenControlling–something must or must not happen Influencing–guideline for which a notification Influencing–guideline for which a notification

must occurmust occur

Page 32: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

3232Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Stating an Action AssertionStating an Action Assertion Anchor Object–an object on which Anchor Object–an object on which

actions are limitedactions are limited Action–creation, deletion, update, or Action–creation, deletion, update, or

readread Corresponding Objects–an object Corresponding Objects–an object

influencing the ability to perform an influencing the ability to perform an action on another business ruleaction on another business rule

Action assertions identify corresponding objects that Action assertions identify corresponding objects that constrain the ability to perform actions on anchor objectsconstrain the ability to perform actions on anchor objects

Page 33: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

3333Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-19 Data model segment for class scheduling

Page 34: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

3434Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-20 Business Rule 1: For a faculty member to be assigned to teach a section of a course, the faculty member must be qualified to teach the course for which that section is scheduled

Action assertion

Anchor object

Corresponding object

Corresponding object

In this case, the action assertion

is a RRestriction

Page 35: 1 Chapter 4: The Enhanced ER Model and Business Rules Modern Database Management 8 th Edition.

3535Chapter 4 © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 4-21 Business Rule 2: For a faculty member to be assigned to teach a section of a course, the faculty member must not be assigned to teach a total of more than three course sections

Action assertionAnchor object

Corresponding object

In this case, the action assertion is an

UUpper LIMLIMit