Chapter-04
Chapter-04
Chapter 4
Entity Relationship (ER) Modeling
1
Learning Objectives
●
Identify the main characteristics of entity relationship
components
●
Describe how relationships between entities are defined,
refined, and incorporated into the database design process
●
See how ERD components affect database design and
implementation
●
Understand that real-world database design often requires the
reconciliation of conflicting goals
2
ERD Styles
●
Chen
– Favors conceptual modeling
●
Crow’s Foot
– More of an implementation-oriented approach
– What this class will focus on
●
UML
– Conceptual and implementation
3
Components
●
Entities
– Nouns in the business rules
●
Attributes
– Characteristics of an entity
●
Relationships
– How entities “link” to each other
4
Entity in ERM
●
Object of interest to the end user
●
Refers to an entity set – not a single occurrence
●
Entities in ERM correspond to tables in the database
●
In ERD
– Entities are represented by rectangles
– Entity names are all capitals
5
ERD Example
6
Attribute Definitions
●
Required attribute
– Attribute must have a value (cannot be NULL)
– Bold in Crow’s foot diagram
●
Optional attribute
– Does not need a value (can be NULL)
– Not bold in Crow’s foot diagram
●
Domain
– Set of potential values for an attribute
7
More Definitions
●
Composite identifier
– Key made up of more than one attribute
●
Composite attribute
– Attribute that can be divided
– Phone number: area code and local number
●
Simple attribute
– Cannot be divided
8
Text Notation
●
TABLE( KEY_ATTR_1, ATTR_2, ATTR_3 )
●
Primary Key
– Bold and underlined, same in Crow’s Foot
●
Required attribute
– Bold
●
Optional attribute
– Not bold
9
More Definitions
●
Single-valued attribute
– Can only have one value at a time
●
Multivalued attribute
– Can have more than one value
– Cannot have in a relational database
– Car color is an example
●
Top color, body color, trim color, interior color
10
Text and ERD
●
CAR (CAR_VIN, MOD_CODE, CAR_YEAR, CAR_COLOR)
●
Note how the primary key is identified
11
Handling Multivalued Attributes
●
Add additional attributes
– How many? What if more are added?
12
Handling Multivalued Attributes
●
Create a new entity
– To me, the best solution
– Note how the foreign key is identified
13
Derived Attributes
●
Attributes that can be computed from other attributes
●
Example
– DATE_OF_BIRTH and AGE
– AGE can be computed
●
Store AGE in the database?
– I say never
14
Derived Attributes
15
Relationships
●
Application of business rules
●
Bidirectional
– A CUSTOMER may generate many INVOICEs
– Each INVOICE is generated by one CUSTOMER
16
Relationship Characteristics
●
Connectivity
– Type of relationship
– 1:1, 1:M, M:N
●
Cardinality
– Minimum and maximum number of occurrences
17
Crow’s Foot Symbols
18
Sometimes Added to ERD
20
Relationship Strength
●
Weak
– Primary key of the related entity does not contain a
primary key component of the parent entity
●
Strong
– Primary key of the related entity contains a primary
key component of the parent entity
21
Weak and Strong Relationships
22
Weak Entities
●
Existence-dependent
●
Has a primary key
that is partially or
totally derived from
parent entity in the
relationship
23
Relationship Participation
●
Optional participation
– One entity occurrence does not require a corresponding
entity occurrence in a particular relationship
●
Mandatory participation
– One entity occurrence requires a corresponding entity
occurrence in a particular relationship
●
Part of cardinality
24
Participation Symbols
25
Relationship Degrees
●
Unary relationship ●
Ternary relationship
– Association is – Three entities are
maintained within a associated
single entity ●
Recursive relationship
●
Binary relationship – Relationship exists
within a single entity type
– Two entities are
associated
26
Examples
27
Composite Entities
28
Developing an ERD
●
Create a detailed narrative of the organization’s description of
operations
●
Identify business rules based on the descriptions
●
Identify main entities and relationships from the business rules
●
Develop the initial ERD
●
Identify the attributes and primary keys that adequately describe
entities
●
Revise and review ERD
29