Professional Documents
Culture Documents
Chapter 2
Entity-Relationship Diagram (ERD)
• An entity-relationship diagram (ERD) is a graphical
representation of the data model representing the proposed
database
2
Entity-Relationship Diagram (ERD)
• An ERD contains three components:
3
Entity-Relationship Diagram (ERD)
• Four goals of ER diagrams:
– Capture all required data
– Ensure data appears only once in the database design
– Does not include any data that is derived from other data already in
the data model
– Arrange data in the data model in a logical manner
4
Entity-Relationship Diagram (ERD)
• ER diagram answers the questions:
– What entities (person, place, or thing) are being represented?
– What attributes (characteristics of data) are stored about each entity?
– What are the relationships between the entities?
– What are the business rules that will determine the structure of the ED
diagram?
– Basically, what data do we want to capture and what are the business
rules surrounding that data
5
Steps to Create ER Diagram
Step Task
1 Identify entities
2 Identify attributes
3 Assign unique identifiers (UID) – primary key (PK)
4 Identify relationships
5 Identify relationship cardinality (and optionality)
6 Assign foreign keys
7 Name relationships
8 Eliminate many-to-many relationships (Chapter 3)
9 Normalize the database (Chapter 4)
10 Define data types (Chapter 5)
6
What is an Entity?
• "Something" of significance to the business about which data
must be captured
• Entity Characteristics:
– Usually a noun
– Singular form
– Upper case
• Examples: CUSTOMER, STUDENT, EMPLOYEE
7
What is an Entity?
• An Entity can be a(n):
– Person – example EMPLOYEE
– Place – example BUILDING
– Object – example PRODUCT
– Event – example CONCERT
9
BDE Consulting Company
The database planning phase has been completed and the database
system has been approved
14
BDE Consulting Company
Requirements Analysis
• BDE is divided into departments. Each department has a unique
department id and department name
• Example:
– An EMPLOYEE entity must require a value for the employee id, first
name and last name attributes
21
Mandatory (Required) Attributes
• Appears as bold in the entity rectangle
22
Optional Attributes
• Attribute that may not have a value or is NULL (unknown)
• Example:
– An EMPLOYEE entity might contain an optional mobile number
• Appears in normal font in the entity
23
Multivalued Attributes
• An attribute that can have more than one value
– A customer may have more than 1 contact number (home, mobile,
office)
– An EMPLOYEE may have more than one dependent
• Consider later
24
Volatile and Derived Attributes
• A volatile attribute contains a value that constantly changes over
time:
– length_of_membership
– years_of_service
– age
• Would have to be updated constantly
25
Volatile and Derived Attributes
• A derived attribute
– Contains a value that can be calculated from existing attributes
– Not stored in the database, but computed when required
– length_of_membership can be calculated using the current date and
membership_date attribute
– years_of_service can be calculated using current date and hire_date
attribute
– Age can be calculated using the current date and birth date
26
Nonvolatile Attributes
• Attributes that rarely change
• Examples:
– Order date
– Birth date
– Hire date
27
Step 2: Define Attributes for
BDE Consulting Company
• Attributes are listed under the entity name in lower case
• Mandatory attributes in bold
• Optional attributes in normal font
• Words are joined with an underline
Step 3: Assign Unique Identifier (UID) /
Primary Key (PK)
• Every entity must have a unique identifier or primary key
• Referred to as primary key in relational (physical) model and
database
29
Unique Identifier (UID)
• A single attribute or a combination of attributes
• Must be unique – Uniquely identifies one and only one instance
of an entity
• A unique identifier value should never change
• Must contain a value – cannot be NULL
• There should be no practical limit to the number of unique
identifier values available
• Only one unique identifier should be specified for each entity.
Remember, an UID can be one or more attributes
Candidate Keys
• Attributes that qualify as UIDs
• Each candidate key must meet the following criteria:
– Same rules as unique identifier
Values must be unique for each instance within the entity
Cannot contain a NULL value
Determine Candidate Keys
• Which attributes qualify as candidate keys?
Candidate Keys
• Candidate keys in red
Step 3: Identify Unique identifiers (UIDs)
• Listed as the first attribute in the box as PK (primary key)
• Must contain a unique value
• Is required and thus specified in bold
• Underlined
diagrams.net for Data Modeling
36