Chapter 5
description
Transcript of Chapter 5
![Page 1: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/1.jpg)
Chapter 5Chapter 5Understanding Entity Relationship Diagrams
![Page 2: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/2.jpg)
Outline Outline
Notation basicsUnderstanding relationshipsGeneralization hierarchiesDiagram rules
![Page 3: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/3.jpg)
Basic SymbolsBasic Symbols
Entity Typesymbol Relationship
symbol
Primary Key
AttributesRelationship
name
Entity Typename
CourseNoCrsDescCrsUnits
Course
OfferNoOffLocationOffTime
Offering
Has
![Page 4: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/4.jpg)
CardinalitiesCardinalities
Course Offering
Course1 Offering1
Course2
Course3
Offering2
Offering3
Offering4
![Page 5: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/5.jpg)
Cardinality NotationCardinality Notation
Inside symbol:minimum cardinality
CourseNoCrsDescCrsUnits
Course
OfferNoOffLocationOffTime
Offering
Has
Perpendicular line:one cardinality
Outside symbol:maximum cardinality
Circle: zerocardinality
Crow's foot: manycardinality
![Page 6: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/6.jpg)
Classification of CardinalitiesClassification of Cardinalities
Minimum cardinality based– Mandatory: existence dependent– Optional
Maximum cardinality based– Functional– 1-M– M-N– 1-1
![Page 7: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/7.jpg)
Summary of CardinalitiesSummary of Cardinalities
Classification Cardinality Restrictions
Mandatory Minimum cardinality 1
Optional Minimum cardinality = 0
Functional or single-valued
Maximum cardinality = 1
1-M Maximum cardinality = 1 in one direction and Maximum cardinality > 1 in the other direction.
M-N Maximum cardinality is > 1 in both directions.
1-1 Maximum cardinality = 1 in both directions.
![Page 8: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/8.jpg)
More Relationship ExamplesMore Relationship Examples
FacSSNFacSalaryFacRankFacHireDate
Faculty
OfferNoOffLocationOffTime
Offering
TeamTeachesOfficeNoOffPhoneOffType
Office
WorksIn
![Page 9: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/9.jpg)
Comparison to Access NotationComparison to Access Notation
CourseNoCrsDescCrsUnits
Course
OfferNoOffLocationOffTime
Offering
Has
ERD (Crow's Foot)
CourseCoursenoCrsDescCrsUnits
1 8OfferingOfferNo
CourseNoOffLocation
OffTime...
Access Relationship Diagram
![Page 10: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/10.jpg)
Understanding RelationshipsUnderstanding Relationships
Identification dependencyM-N relationships with attributesSelf identifying relationshipsM-way relationshipsEquivalence between M-N and 1-M
relationships
![Page 11: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/11.jpg)
Identification DependencyIdentification Dependency
BldgIDBldgNameBldgLocation
Building
RoomNoRoomCapacity
Room
Contains
Identification Dependency Symbols: Solid relationship line for identifying
relationships Diagonal lines in the corners denote
weak entities.
![Page 12: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/12.jpg)
M-N Relationships M-N Relationships with Attributeswith Attributes
StdSSNStdName
StudentOfferNoOffLocationOffTime
Offering
EnrollsIn
EnrGrade
attribute of relationship
![Page 13: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/13.jpg)
M-N Relationships M-N Relationships with Attributes (II)with Attributes (II)
AuthNoAuthName
AuthorISBNTitle
Book
AuthOrder
b) Writes relationship
Writes
PartNoPartName
PartSuppNoSuppName
Supplier
Qty
Provides
a) Provides relationship
![Page 14: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/14.jpg)
Instance Diagrams for Self-Instance Diagrams for Self-Referencing RelationshipsReferencing Relationships
Faculty1
Faculty2 Faculty3
Faculty4 Faculty5
IS300
IS320
IS480 IS460
IS461
(a) Supervises (b) PreReqTo
![Page 15: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/15.jpg)
ERD Notation for Self-ERD Notation for Self-Referencing RelationshipsReferencing Relationships
FacSSNFacName
Faculty
a) manager-subordinate
Supervises
b) course prerequisites
CourseNoCrsDesc
Course PrereqTo
![Page 16: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/16.jpg)
Associative Entity Types for Associative Entity Types for M-way RelationshipsM-way Relationships
PartNoPartName
PartSuppNoSuppName
Supplier
Associativeentity type
ProjNoProjName
Project
UsesPart-Uses
Supp-Uses
Proj-Uses
![Page 17: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/17.jpg)
Relationship EquivalenceRelationship Equivalence
Replace M-N relationship – Associative entity type– Two identifying 1-M relationships
M-N relationship versus associative entity type– Largely preference– Associative entity type is more flexible in some
situations
![Page 18: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/18.jpg)
Associative Entity Type ExampleAssociative Entity Type Example
StdSSNStdName
StudentOfferNoOffLocationOffTime
Offering
EnrGrade
EnrollmentRegisters GrantsAttDatePresent
Attendance
RecordedFor
![Page 19: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/19.jpg)
Generalization HierarchiesGeneralization Hierarchies
EmployeeEmpNo
EmpNameEmpHireDate
...
SalaryEmpEmpSalary
HourlyEmpEmpRate
generalization hierarchysymbol
supertype
subtypes
![Page 20: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/20.jpg)
InheritanceInheritance
Subtypes inherit attributes of supertypes (direct and indirect)
Allows abbreviation of attribute listApplies to code (methods) as well as
attributes (data)
![Page 21: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/21.jpg)
Generalization ConstraintsGeneralization Constraints
BondRate
FaceValue
StockOutShares
IssuedShares
SecuritySymbol
SecNameLastClose
D,C
DisjointnessConstraint
CompletenessConstraint
![Page 22: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/22.jpg)
Multiple Levels of Multiple Levels of GeneralizationGeneralization
SecuritySymbol
SecNameLastClose
StockOutShares
IssuedShares
BondRate
FaceValue
D,C
CommonPERatioDividend
PreferredCallPriceArrears
D,C
![Page 23: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/23.jpg)
Comprehensive ExampleComprehensive Example
OfferingOfferNoOffLocationOffTime
EnrGrade
EnrollmentRegisters
Grants
CourseNoCrsDescCrsUnits
Course
FacultyFacSalaryFacRankFacHireHate
SSNNameCityStateZip
UnivPerson
Has
Teaches
Supervises
CStudentStdClassStdMajorStdGPA
![Page 24: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/24.jpg)
Diagram RulesDiagram Rules
Ensure that ERD notation is correctly usedSimilar to syntax rules for a computer
languageCompleteness rules: no missing
specificationsConsistency rules: no conflicts among
specificationsSupported by the ER Assistant
![Page 25: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/25.jpg)
Completeness RulesCompleteness Rules Primary Key Rule: all entity types have a PK (direct,
indirect, or inherited) Naming Rule: all entity types, relationships, and
attributes have a name Cardinality Rule: cardinality is specified in both
directions for each relationship Entity Participation Rule: all entity types participate in an
at least one relationship except for entity types in a generalization hierarchy
Generalization Hierarchy Participation Rule: at least one entity type in a generalization hierarchy participates in a relationship
![Page 26: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/26.jpg)
Primary Key Rule IssuePrimary Key Rule Issue
Primary key rule is simple in most casesFor some weak entities, the PK rule is
subtle
– Weak entity with only one 1-M identifying relationship
– Weak entity must have a local key to augment the borrowed PK from the parent entity type
– Violation of PK rule if local key is missing
![Page 27: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/27.jpg)
PK Rule Violation ExamplePK Rule Violation Example
BldgIDBldgNameBldgLocation
BuildingRoomRoomNoRoomCapacity
Contains
PK rule violation A single 1-M identifying relationship Room does not have a local key.
![Page 28: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/28.jpg)
Naming Consistency RulesNaming Consistency Rules
Entity Name Rule: entity type names must be unique
Attribute Name Rule: attribute names must be unique within each entity type and relationship
Inherited Attribute Rule: attribute names in a subtype do not match inherited (direct or indirect) attribute names.
![Page 29: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/29.jpg)
Connection Consistency RulesConnection Consistency Rules
Relationship/Entity Connection Rule: relationships connect two entity types (not necessarily distinct)
Relationship/Relationship Connection Rule: relationships are not connected to other relationships
Redundant Foreign Key Rule: foreign keys are not used.
![Page 30: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/30.jpg)
Identification Dependency RulesIdentification Dependency Rules
Weak entity rule: weak entities have at least one identifying relationship
Identifying relationship rule: at least one participating entity type must be weak for each identifying relationship
Identification dependency cardinality rule: the minimum and maximum cardinality must equal 1 for a weak entity in all identifying relationships
![Page 31: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/31.jpg)
Example of Diagram ErrorsExample of Diagram Errors
OfferingOfferNoOffLocationOffTimeCourseNo
EnrGrade
EnrollmentRegisters Grants
CourseNoCrsDescCrsUnits
Course
FacultyFacSalaryFacRankFacHireHate
SSNNameCityStateZip
UnivPerson
Has
Teaches
Supervises
CStudentStdClassStdMajorStdGPA
Rule 6 Violation(Weak Entity)
Rule 7 Violation(Identifying Relationship)Rule 8 Violation
(Id Dependency Cardinality)
Rule 9 Violation(Redundant FK)
![Page 32: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/32.jpg)
Corrected ERDCorrected ERD
OfferingOfferNoOffLocationOffTime
EnrGrade
EnrollmentRegisters
Grants
CourseNoCrsDescCrsUnits
Course
FacultyFacSalaryFacRankFacHireHate
SSNNameCityStateZip
UnivPerson
Has
Teaches
Supervises
CStudentStdClassStdMajorStdGPA
![Page 33: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/33.jpg)
Support in the ER AssistantSupport in the ER Assistant
Version 2 of the ER Assistant supports the diagram rules
Relationship formation rules are supported by diagram construction
Other rules are supported by the Check Diagram feature
For the Redundant Foreign Key rule, the ER Assistant detects FKs that have the same name as the associated PKs
![Page 34: Chapter 5](https://reader030.fdocuments.us/reader030/viewer/2022033100/56814748550346895db48593/html5/thumbnails/34.jpg)
SummarySummary
Data modeling is an important skillCrow’s Foot ERD notation is widely usedUse notation preciselyUse the diagram rules to ensure structural
consistency and completenessUnderstanding the ERD notation is a
prerequisite to applying the notation on business problems