DB Systems - Chapter 2 - ER Model
DB Systems - Chapter 2 - ER Model
Chapter 2:
The Entity-Relationship Model
Database Systems
(CO2013)
Computer Science Program
Assoc. Prof. Dr. Võ Thị Ngọc Châu
([email protected])
Semester 1 – 2022-2023
Content
Chapter 1: An Overview of Database Systems
2
Chapter 2:
The Entity-Relationship Model
2.1. Database design process from
conceptual modeling
Conceptual design
The entity-relationship model
Physical design
5
2.1. Database design process
from conceptual modeling
The main phases
of database design
Source: [1] 6
2.2. Conceptual Data Modeling
Data modeling
Database design
Relational database design
7
2.2. Conceptual Data Modeling
Modeling - Cambridge dictionary
Model = a representation of something, either
as a physical object which is usually smaller
than the real object, or as a simple description
of the object which might be used in calculations
Source: G. Simsion, Data Modeling: Theory and Practice, Technics Publications, LLC, 2007.
10
Data modeling - pp. 31-32.
2.2. Conceptual Data Modeling
Data modeling
―Data modeling is generally viewed as a design
activity‖
Srinivasan and Te‘eni, 1990
―an activity that involves the creation of
abstractions‖
Davydov, 1994
―the art and science of arranging the structure
and relationship of data‖
McComb, 2004, p.293
―data modeling is a design discipline‖
Simsion and Witt, 2005, p.7
Source: G. Simsion, Data Modeling: Theory and Practice, Technics Publications, LLC, 2007.
11
Data modeling - pp. 31-32.
Why is data modeling important?
Leverage
Make programming simpler and cheaper
Poor data organization can be expensive to fix.
Conciseness
Take more directly to the heart of the business requirements
Data quality
Problems with data quality can be traced back to a lack of
consistency in:
Defining and interpreting data
Implementing mechanisms to enforce the definitions
A key role in achieving good data quality by establishing a
common understanding of what is to be held in each table
and column and how it is to be interpreted
12
G. C. Simsion, G. C. Witt, Data modeling essentials – 3rd edition, Elsevier Inc, 2005, pp. 8-10.
2.2. Conceptual Data Modeling
A data model (aka semantic data model)
Provides concepts close to the way many users
perceive data
Choice of a DBMS
Approaches
24
Database design
Phase 3: Choice of a DBMS
Technical factors
Suitability & type of the DBMS for the task
Storage structures and access paths, the user and
programmer interfaces, high-level query languages,
development tools, architectural options, … supported by
DBMS
DBMS portability among different types of hardware
Non-technical factors
Cost: software acquisition cost, maintenance cost, hardware
acquisition cost, database creation and conversion cost,
personnel cost, training cost, operating cost
Availability of vendor services
… 25
Database design
Phase 4: Data Model Mapping (Logical
Database Design)
Relationship types
Attributes
Key attributes
Structural constraints
…
31
The Entity-Relationship Model
P. P-S. Chen. The Entity-Relationship Model – Toward a Unified View of
Data. ACM Transactions on Database Systems 1(1)(March 1976) 9-36.
Dependent Dependents of an
Weak entity type
employee
Employee works_on
works_on Relationship type
Project
Identifying Dependents
dependents_of relationship type of dependents_of
the weak entity type Employees
32
Symbol Meaning Example
Attribute of an entity
Name Name of an employee
or relationship
Distinct identifier of an
EmployeeID Key Attribute
employee
Phone numbers of an
PhoneNumber Multivalued Attribute
employee
Age of an employee
Age Derived Attribute (derived from attribute
―date of birth”)
33
The Entity-Relationship Model
P. P-S. Chen. The Entity-Relationship Model – Toward a Unified View of
Data. ACM Transactions on Database Systems 1(1)(March 1976) 9-36.
Constraints
34
A sample database application -
COMPANY
The COMPANY database keeps track of a company‘s employees, departments, and
projects. Suppose that after the requirements collection and analysis phase, the
database designers provide the following description of the miniworld that will be
represented in the database:
- The company is organized into departments. Each department has a unique name,
a unique number, and a particular employee who manages the department. We keep
track of the start date when that employee began managing the department. A
department may have several locations.
- A department controls a number of projects, each of which has a unique name, a
unique number, and a single location.
- The database will store each employee‘s name, Social Security number (SSN),
address, salary, sex (gender), and birth date. An employee is assigned to one
department, but may work on several projects, which are not necessarily controlled
by the same department. It is required to keep track of the current number of hours
per week that an employee works on each project, as well as the direct supervisor of
each employee (who is another employee).
- The database will keep track of the dependents of each employee for insurance
purposes, including each dependent‘s first name, sex, birth date, and relationship to
the employee. 35
An ER schema diagram for the
COMPANY database
Source: [1] 36
The Entity-Relationship Model
P. P-S. Chen. The Entity-Relationship Model – Toward a Unified View of
Data. ACM Transactions on Database Systems 1(1)(March 1976) 9-36.
38
The Entity-Relationship Model
P. P-S. Chen. The Entity-Relationship Model – Toward a Unified View of
Data. ACM Transactions on Database Systems 1(1)(March 1976) 9-36.
39
The Entity-Relationship Model
P. P-S. Chen. The Entity-Relationship Model – Toward a Unified View of
Data. ACM Transactions on Database Systems 1(1)(March 1976) 9-36.
41
The Entity-Relationship Model
P. P-S. Chen. The Entity-Relationship Model – Toward a Unified View of
Data. ACM Transactions on Database Systems 1(1)(March 1976) 9-36.
address EMPLOYEE
42
The Entity-Relationship Model
P. P-S. Chen. The Entity-Relationship Model – Toward a Unified View of
Data. ACM Transactions on Database Systems 1(1)(March 1976) 9-36.
Attribute
Complex Attributes
{Address_phone( {Phone(Area_code,Phone_number)},
Address(Street_address
(Number,Street,Apartment_number), City,State,Zip) )}
Phone: composite, multivalued
Street_address: composite
Address: composite
Address_phone: composite, multivalued
Apartment_
Number Street
number
EMPLOYEE 46
List all the entity types and their attributes.
Classify their attributes.
WORKS_FOR
DEPARTMENT
1 N
SUPERVISES
49
The Entity-Relationship Model
P. P-S. Chen. The Entity-Relationship Model – Toward a Unified View of
Data. ACM Transactions on Database Systems 1(1)(March 1976) 9-36.
EMPLOYEE
MANAGES
DEPARTMENT
EMPLOYEE
WORKS_FOR
DEPARTMENT
EMPLOYEE
WORKS_ON
PROJECT
M N
N 1
VEHICLE SALES CUSTOMER
1
Sid SALESPERSON
56
The Entity-Relationship Model
P. P-S. Chen. The Entity-Relationship Model – Toward a Unified View of
Data. ACM Transactions on Database Systems 1(1)(March 1976) 9-36.
SSN NAME
1 N
DEPENDENTS
EMPLOYEE DEPENDENTS_OF DEPENDENT
_OF
65
- Disjoint (d): the subclasses of the specialization must be disjoint.
- Overlapping (o): the subclasses are not constrained to be disjoint,
their sets of entities may overlap.
a. List superclasses,
subclasses of each
superclass
b. List class/subclass
relationships
c. Describe constraints on
each specialization
67
Two categories (union types): OWNER and
REGISTERED_VEHICLE
Source: [1]
68
Summary
Data modeling: conceptual, logical
Database design process: 6 phases
Requirements collection and analysis
Conceptual database design
The entity-relationship model
Choice of a DBMS a representational data model
The relational data model
Structural constraints
…
70
Summary
Enhanced Entity-Relationship Modeling
Subclass, superclass, attribute and relationship
inheritance
Partial (–)
71
Chapter 2:
The Entity-Relationship Model
72
Review
2.1. Distinguish entity types and weak entity
types, relationships and identifying
relationships.
2.2. Give examples to differentiate between
simple and composite attributes, between
single-valued and multivalued attributes,
between stored and derived attributes.
2.3. How can we make a choice of entity,
attribute, and relationship in conceptual data
modeling with the Entity-Relationship model?
Give an example to justify your suggestions.
73
Review
2.4. Design an E-R diagram of a university
database application. The university database
maintains records of its departments,
lecturers, course modules, and students. The
requirements are summarised as follows:
The university consists of departments. Each department has
a unique name and some other descriptive attributes.
A department must also have a number of lecturers. One of
them is the head of the department.
All lecturers have unique identifiers and different names. They
must teach one or more modules. A lecturer can only belong
to one department.
Modules are offered by departments and taught by lecturers.
They must also be attended by some students. Each module
has a unique module number.
Students must enrol for a number of modules. Each student is
given a unique student number. 74
Review
2.5. Consider the E-R diagram which shows a
simplified schema for an airline reservations
system.
a. List the strong (non-weak) entity types in the ER
diagram.
b. Is there any weak entity type? If yes, give its
name, partial key, and identifying relationship.
c. What constraints do the partial key and the
identifying relationship of the weak entity type specify
in this diagram?
d. Describe all the relationship types and specify the
(min, max) constraint on each participation of an
entity type in a relationship type. Justify your choices.
75
Review
2.5. Consider the
E-R diagram
which shows a
simplified schema
for an airline
reservations
system.
76
Review
2.6. Consider the following EER diagram
that describes the computer systems at a
company. Provide your own attributes and
key for each entity type. Supply max
cardinality constraints justifying your
choice. Write a complete narrative
description of what this EER diagram
represents.
77
Review
12345 r2 r5 D0003
Fac02
09872 r3 r6 D0007
1 N 1 N
Faculty Department Staff
Operates Has
r5 D0003 r2 12345
Fac02
r6 D0007 r3 09872
M N M N
EMPLOYEE PROJECT LOCATION
works_on is_at
10978 r1 01 r4 L0001
12345 r2 r5 L0003
02
r3 r6 L0005
09872 r4 r7 L0007
Controls
Project P123
belongs to
department
D0003.
88
Next
Chapter 3: The Relational Data Model
3.1. Concepts