Chapter - 3
Chapter - 3
Chapter - 3
SYSTEMS(ITEC2071)
Data Modeling Using the Entity-Relationship
(ER) Model
Outline
2
Application design
Project Initiation
and Planning
Conceptual data modeling
Analysis
Simple
Each entity has a single atomic value for the attribute. For example, SSN
or Sex.
Composite
The attribute may be composed of several components. For example,
Address (Apt#, House#, Street, City, State, ZipCode, Country) or Name
(FirstName, MiddleName, LastName). Composition may form a
hierarchy where some components are themselves composite.
Multi-valued
An entity may have multiple values for that attribute. For example, Color
of a CAR or Previous Degrees of a STUDENT. Denoted as {Color} or
{Previous Degrees}.
Null Values
NULL applies to attributes which are not applicable or
which do not have values.
You may enter the value NA (meaning not applicable)
CAR
Registration(RegistrationNumber, State), VehicleID, Make, Model, Year, (Color)
car1
((ABC 123, TEXAS), TK629, Ford Mustang, convertible, 1999, (red, black))
car2
((ABC 123, NEW YORK), WP9872, Nissan 300ZX, 2-door, 2002, (blue))
car3
((VSY 720, TEXAS), TD729, Buick LeSabre, 4-door, 2003, (white, blue))
.
.
.
ENTITY TYPE
RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
TOTAL PARTICIPATION OF E2 IN R
22
Weak Entity Types
23
An entity that does not have a key attribute
A weak entity must participate in an identifying relationship type with an
Example:
Suppose that a DEPENDENT entity is identified by the dependent’s first
name and birth date, and the specific EMPLOYEE that the dependent is
related to. DEPENDENT is a weak entity type with EMPLOYEE as its
identifying entity type via the identifying relationship type
DEPENDENT_OF
has:
Cardinality - The number of instances of entity B that can
be associated with each instance of entity A.
Minimum Cardinality or Modality - The minimum
number of instances of entity B that may be associated
with each instance of entity A.
Maximum Cardinality - The maximum number of
instances of entity B that may be associated with each
instance of entity A
Data
24 Modeling Using the Entity-Relationship
10/01/22 (ER) Model
Entity Relationship Diagrams for Data Modelling
Relationships
A one-to-one relationship (1:1) exists when the maximum
Data
25 Modeling Using the Entity-Relationship
10/01/22 (ER) Model
Entity Relationship Diagrams for Data Modelling
Types of entity relationships and example of their representation:
Data
26 Modeling Using the Entity-Relationship
10/01/22 (ER) Model
Entity Relationship Diagrams for Data Modelling
Implement One-to-One Relationships
In a relational database, one-to-one relationships between entities
can be implemented by merging the two tables/entities together.
Implement One-to-Many Relationships
Place the primary key of the entity that can occur only once as a
foreign key in the entity that can occur many times.
Implement Many-to-Many Relationships
In a relational database, many-to-many relationships between
entities can be implemented by creating a new entity that links the
other two entities together. In most cases, the primary key of the
new entity consists of the primary keys of the entities that it is
relating together.
Spit it into two one-to-many relationships!
Data
27 Modeling Using the Entity-Relationship
10/01/22 (ER) Model
Entity Relationship Diagrams for Data Modelling
28
Student Module
Student ID (pk) Module ID(pk)
Student first name Module name
Student last name Module Credits
… …
Student Module
Enrollment Module ID(pk)
Student ID (pk) Module ID (pk) + (fk) in Module name
Student first name Student ID (pk) + (fk)
Student last name Module Credits
… …
Example
In a University database we might have entities for
Students, Modules and Lecturers. Students might have
attributes such as their ID, Name, and Course, and
could have relationships with Modules (enrolment) and
Lecturers (tutor/tutee)
In an E/R Diagram, an
entity is usually drawn as a Lecturer ID
Module Studies
In an E/R Diagram
attributes may be drawn as Lecturer ID
Module Studies
Module Studies
One Many
Many to many
relationships are difficult to Student
represent
We can split a many to Student
Has
many relationship into two
one to many relationships
Studies Enrolment
An entity represents the
M:M relationship
In
Module
Module
Department
Student
Offers Department
Student
Offers Department
Student
Offers Department
Enrols In Student
Offers Department
Takes
Enrols In Student
Offers Department
Takes
Enrols In Student
Takes
Enrols In Student
Takes
Takes
Price
Description Product
Street address
Price
Description Product
redundant relationship
together b A B y
b AB y
c z
Price
Description Product
Has A
Module
Has
In