36
Chapter Chapter 4: The Enhanced E The Enhanced E-R Model and R Model and Business Rules Business Rules Business Rules Business Rules Modern Database Management Modern Database Management 9 th th Edition Edition 9 Edition Edition Jeffrey A. Jeffrey A. Hoffer Hoffer, Mary B. Prescott, , Mary B. Prescott, Heikki Heikki Topi Topi © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice Hall Publishing as Prentice Hall 1

Chapter Chapter 44:: The Enhanced Ehe Enhanced E--R …is.cba.edu.kw/433/Handouts/ch04.pdf · Chapter Chapter 44:: The Enhanced Ehe Enhanced E--R Model and R Model and Business RulesBusiness

  • Upload
    lythien

  • View
    226

  • Download
    0

Embed Size (px)

Citation preview

Chapter Chapter 44::The Enhanced EThe Enhanced E--R Model and R Model and

Business RulesBusiness RulesBusiness RulesBusiness Rules

Modern Database ManagementModern Database Management99thth EditionEdition99 EditionEdition

Jeffrey A. Jeffrey A. HofferHoffer, Mary B. Prescott, , Mary B. Prescott, HeikkiHeikki TopiTopi

© © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 11

ObjectivesObjectivesObjectivesObjectivesD fi iti f tD fi iti f tDefinition of termsDefinition of termsUse of Use of supertypesupertype/subtype relationships/subtype relationshipsUse of generalization and specialization techniquesUse of generalization and specialization techniquesUse of generalization and specialization techniquesUse of generalization and specialization techniquesSpecification of completeness and Specification of completeness and disjointnessdisjointnessconstraintsconstraintsconstraintsconstraintsDevelop Develop supertypesupertype/subtype hierarchies for realistic /subtype hierarchies for realistic business situationsbusiness situationsDevelop entity clustersDevelop entity clustersExplain universal data modelExplain universal data modelName categories of business rulesName categories of business rules

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 22

Supertypes and SubtypesSupertypes and SubtypesSupertypes and SubtypesSupertypes and Subtypes

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

b ib isubgroupingssubgroupings

Supertype:Supertype: A generic entity type that has a A generic entity type that has a l ti hi ith btl ti hi ith btrelationship with one or more subtypesrelationship with one or more subtypes

Attribute Inheritance:Attribute Inheritance:Subtype entities inherit values of all attributes of Subtype entities inherit values of all attributes of the supertypethe supertypeAn instance of a subtype is also an instance of theAn instance of a subtype is also an instance of theAn instance of a subtype is also an instance of the An instance of a subtype is also an instance of the supertypesupertype

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 33

Figure 4-1 Basic notation for supertype/subtype notation

a) EER notationnotation

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 44

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

b) Microsoft Visio

Notation

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

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 55

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

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 66

Relationships and SubtypesRelationships and Subtypes

Relationships at the Relationships at the supertypesupertype level level indicate that all subtypes will participate in indicate that all subtypes will participate in the relationshipthe relationshipppThe instances of a The instances of a subtypesubtype may may participate in a relationship unique to thatparticipate in a relationship unique to thatparticipate in a relationship unique to that participate in a relationship unique to that subtype. In this situation, the relationship subtype. In this situation, the relationship is shown at the subtype levelis shown at the subtype level

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 77

Figure 4-3 Supertype/subtype relationships in a hospital

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

Only resident patients are assigned to a bed

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 88

Generalization andGeneralization andGeneralization and Generalization and SpecializationSpecializationpp

Generalization:Generalization: The process of The process of defining a more general entity type from a defining a more general entity type from a set of more specialized entity types.set of more specialized entity types.set of more specialized entity types. set of more specialized entity types. BOTTOMBOTTOM--UPUP

S i li tiS i li tiSpecialization:Specialization: The process of defining The process of defining one or more subtypes of the supertype one or more subtypes of the supertype yp p ypyp p ypand forming supertype/subtype and forming supertype/subtype relationships TOPrelationships TOP--DOWNDOWN

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 99

relationships. TOPrelationships. TOP DOWNDOWN

Figure 4-4 Example of generalization

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

All these types of vehicles have common attributes

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1010

Figure 4-4 Example of generalization (cont.)

b) Generalization to VEHICLE supertype

So we put the shared

ib iattributes in a supertype

b f l i i h i ibChapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1111

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

Figure 4-5 Example of specialization

a) Entity type PARTa) Entity type PART

Only applies to manufactured partsp

Applies only to purchased parts

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1212

b) Specialization to MANUFACTURED PART and PURCHASED PART

Figure 4-5 Example of specialization (cont.)b) Specialization to MANUFACTURED PART and PURCHASED PART

Created 2Created 2 subtypes

Note: multivalued attribute was replaced by an

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1313

p yassociative entity relationship to another entity

Constraints in Supertype/Constraints in Supertype/Constraints in Supertype/ Constraints in Supertype/ Completeness ConstraintCompleteness Constraintpp

Completeness ConstraintsCompleteness Constraints::Completeness ConstraintsCompleteness Constraints: : Whether an instance of a supertype Whether an instance of a supertype mustmust also be a member of at least one also be a member of at least one subtypesubtypesubtypesubtype

Total Specialization Rule: Yes (double line)Total Specialization Rule: Yes (double line)Partial Specialization Rule: No (single line)Partial Specialization Rule: No (single line)

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1414

Figure 4-6 Examples of completeness constraintsa) Total specialization rule) p

A patient must be either an outpatient or a

id t ti tresident patient

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1515

b) Partial specialization ruleFigure 4-6 Examples of completeness constraints (cont.)

b) Partial specialization rule

A vehicleA vehicle could be a car, a truck,

ithor neither

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1616

Constraints in Supertype/Constraints in Supertype/Constraints in Supertype/ Constraints in Supertype/ Disjointness constraintDisjointness constraintjj

Disjointness ConstraintsDisjointness Constraints: Whether : Whether jjan instance of a supertype may an instance of a supertype may simultaneouslysimultaneously be a member of two (orbe a member of two (orsimultaneouslysimultaneously be a member of two (or be a member of two (or more) subtypesmore) subtypes

Disjoint Rule: An instance of the supertypeDisjoint Rule: An instance of the supertypeDisjoint 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 subtypesOverlap 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

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1717

a) Disjoint rule

Figure 4-7 Examples of disjointness constraints

a) Disjoint rule

A patient can either be outpatient p por resident, but not both

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1818

b) Overlap ruleFigure 4-7 Examples of disjointness constraints (cont.)

) p

A part may be both purchased andpurchased and manufactured

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 1919

Constraints in Supertype/Constraints in Supertype/Constraints in Supertype/ Constraints in Supertype/ Subtype DiscriminatorsSubtype Discriminatorsypyp

Subtype DiscriminatorSubtype Discriminator: An attribute of the : An attribute of the supertype whose values determine the target supertype whose values determine the target subtype(s)subtype(s)

DisjointDisjoint –– a a simplesimple attribute with alternative values attribute with alternative values to indicate the possible subtypesto indicate the possible subtypesOverlappingOverlapping –– a a compositecomposite attribute whose subparts attribute whose subparts pertain to different subtypes. Each subpart contains a pertain to different subtypes. Each subpart contains a boolean value to indicate whether or not the instanceboolean value to indicate whether or not the instanceboolean value to indicate whether or not the instance boolean value to indicate whether or not the instance belongs to the associated subtypebelongs to the associated subtype

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2020

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

A simple attribute with different possible values indicating the subtype

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2121

Figure 4-9 Subtype discriminator (overlap rule)

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

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2222

Figure 4-10 Example of supertype/subtype hierarchy

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2323

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 relationshipsrelationshipsppSolution: Group entities and relationships Solution: Group entities and relationships intointo entity clustersentity clustersinto into entity clustersentity clustersEntity clusterEntity cluster: Set of one or more entity : Set of one or more entity yy yytypes and associated relationships types and associated relationships grouped into a single abstract entity typegrouped into a single abstract entity type

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2424

grouped into a single abstract entity typegrouped into a single abstract entity type

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

Related groups ofgroups of entities could become clusters

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2525

Figure 4-13b EER diagram of PVF entity clusters

More readable, isn’t it?isn t it?

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2626

Figure 4-14 Manufacturing entity cluster

Detail for a single cluster

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2727

Figure 4-15 PARTY, PARTY ROLE, and ROLE TYPE in a universal data model

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

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2828

Business RulesBusiness RulesBusiness RulesBusiness Rules

Statements that Statements that definedefine or or constrainconstrain some aspect of some aspect of the businessthe businessthe businessthe businessClassification of business rules:Classification of business rules:

DerivationDerivation rule derived from other knowledge often inrule derived from other knowledge often inDerivationDerivation––rule derived from other knowledge, often in rule derived from other knowledge, often in the form of a formula using attribute valuesthe form of a formula using attribute valuesStructural assertionStructural assertion––rule expressing static structurerule expressing static structureStructural assertionStructural assertion rule expressing static structure. rule expressing static structure. Includes attributes, relationships, and definitionsIncludes attributes, relationships, and definitionsAction assertionAction assertion––rule expressing constraints/control ofrule expressing constraints/control ofAction assertionAction assertion rule expressing constraints/control of rule expressing constraints/control of organizational actionsorganizational actions

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 2929

Figure 4-18EER diagram to describe business rules

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 3030

Types of Action AssertionsTypes of Action AssertionsypypResultResult

C ditiC diti IF/THEN lIF/THEN lConditionCondition––IF/THEN ruleIF/THEN ruleIntegrity constraintIntegrity constraint––must always be truemust always be trueAuthorizationAuthorization privilege statementprivilege statementAuthorizationAuthorization––privilege statementprivilege statement

FormFormEnablerEnabler leads to creation of new objectleads to creation of new objectEnablerEnabler––leads to creation of new objectleads to creation of new objectTimerTimer––allows or disallows an actionallows or disallows an actionExecutiveExecutive––executes one or more actionsexecutes one or more actionsExecutiveExecutive––executes one or more actionsexecutes one or more actions

RigorRigorControllingControlling something must or must not happensomething must or must not happenControllingControlling––something must or must not happensomething must or must not happenInfluencingInfluencing––guideline for which a notification must guideline for which a notification must occuroccur

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 3131

o uo u

Stating an Action AssertionStating an Action Assertion

Anchor ObjectAnchor Object––an object on which actions an object on which actions are limitedare limitedare limitedare limitedActionAction––creation, deletion, update, or readcreation, deletion, update, or readC di Obj tC di Obj t bj tbj tCorresponding ObjectsCorresponding Objects––an object an object influencing the ability to perform an action influencing the ability to perform an action

th b i lth b i lon another business ruleon 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

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 3232

y p jy p j

Figure 4-19 Data model segment for class scheduling

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 3333

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 toteach a section of a course, the faculty member must be qualified to teach the course for which that section is scheduled

Corresponding object

In this case the

Action assertion

In this case, the action assertion is a RRestriction

Action assertion

Anchor object

Corresponding object

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 3434

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 y gteach a total of more than three course sections

Corresponding

In this case, the action assertion

objectis anUUpper LIMLIMit

Action assertionAnchor object

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 3535

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means electronicretrieval system, or transmitted, in any form or by any means, electronic,

mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America.

Copyright © Copyright © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall

Chapter 4 © © 2009 2009 Pearson Education, Inc. Pearson Education, Inc. Publishing as Prentice HallPublishing as Prentice Hall 3636