Lecture 2VBET
Lecture 2VBET
Entity-Relationship Model
(Chapter 3)
Database Management
COP4540, SCS, FIU
Entity-Relationship Model
E-R model was introduced by Peter Chen in
1976
It is a graphical approach to database
modeling.
It describes data as entities, relationships
and attributes.
Database Management
COP4540, SCS, FIU
Elements of ER Model
Key elements:
Entities
Attributes
Relationships
Identifiers
Database Management
COP4540, SCS, FIU
Entities
An entity is the basic object that the E-R
model represents
An entity is something that can be identified
in real world.
Examples
Peter Johns, MIS, 12345
May Carson, CS, 67890
Dee Conway, 1134, CS, Prof.
Entities (2)
Name
Peter Johns
May Carson
FACULTY
Major
MIS
CS
Name StaffID
Dee Conway
Year
2
1
ID
12345
67890
Dept
CS
Post
Prof
Entity Instances
Entity Class
STUDENT
Database Management
COP4540, SCS, FIU
Attributes
Entities have attributes that describe the
entitys characteristics.
Types of attributes: single-valued, multivalued, composite. Example are:
Single-value: Year 2
Multi-valued: {MIS, Marketing}
Composite: (FirstName, LastName)
Database Management
COP4540, SCS, FIU
Relationships
A relationship indicated how one or more
entity classes interact with one and another.
Each entity plays a role in a relationship.
Degree of the relationship: number of
entities in a relationship.
Understanding the relationship is important
because it will affect how the database is
constructed and used.
Database Management
COP4540, SCS, FIU
E-R Concepts
entity type = entity class = entity
entity instance = entity occurrence = record
entity type: a set of objects in the real world
with the same properties (not the same
values) with a physical or conceptual
existence
entity instance: each entity has its own
values for each attribute
Database Management
COP4540, SCS, FIU
Attribute
Weak Entity
Multivalued Attribute
Relationship
Derived Attribute
Identifying Relationship
Database Management
COP4540, SCS, FIU
Unary
Binary
Ternary
Database Management
COP4540, SCS, FIU
Database Management
COP4540, SCS, FIU
Database Management
COP4540, SCS, FIU
Composite Attribute
Address
Street
City
State
Zip
Database Management
COP4540, SCS, FIU
Years_Employed
Name
EMPLOYEE
Address
Skills
Date_Employed
Database Management
COP4540, SCS, FIU
Other_Attributes
STUDENT
Database Management
COP4540, SCS, FIU
Date
Number_of_Passengers
Flight_ID
FLIGHT
Database Management
COP4540, SCS, FIU
FName
Name
Tel
STUDENT
SSN
DOB
Age
Database Management
COP4540, SCS, FIU
Derived Attributes
Example 1: Age = today date - DOB
Example 2: total number of staff can be
calculated by counting the total number of
staff entity instances.
Example 3: deposit = 2 * rent
Database Management
COP4540, SCS, FIU
BRANCH
Tel_No
Fax_No
Address
Street
ZipCode
City
Database Management
COP4540, SCS, FIU
Relationships
Definition: a meaningful association among
entity classes.
Meaningful implies that the relationship
allows us to answer questions that could not
be answered given only the entity classes.
In general, any number of entity classes
may participate in a relationship.
Database Management
COP4540, SCS, FIU
Relationships
Relationship type versus Instance
Degree of Relationship - number of entity
types that participate in it
A relationship is represented by a diamond
in the diagram with lines linking to the
corresponding entity classes.
CourseId
Professors
name
teaching
Courses
Database Management
COP4540, SCS, FIU
Relationship Set
Think of the value of relationship set as a table
One column for each of the connected entity sets.
One row for each list of entities, one from each set,
which is connected by the relationship.
Professors
Courses
Holmes
COP3337
Barton
COP4610
Milani
COP4010
Database Management
COP4540, SCS, FIU
Relationships
Degree of Relationship
Unary Relationship
Binary Relationship
Ternary Relationship
Attributes of Relationship
Many to Many
Database Management
COP4540, SCS, FIU
1
PERSON
Is_married_to
EMPLOYEE
Manages
1
One-to-one
1
One-to-many
Database Management
COP4540, SCS, FIU
Role Names
Unary relationship: the same entity class
participates more than once in different
roles.
Supervisor
1
Supervises
EMP
Supervisee
Database Management
COP4540, SCS, FIU
EMPLOYEE
Assigned
PARKING PLACE
One-to-one
PRODUCT LINE
Contains
PRODUCT
One-to-many
STUDENT
Registers N
Many-to-many
COURSE
Database Management
COP4540, SCS, FIU
Role Names
Role names may also be used when two
entity classes are associated through more
than one relationships
manager
Manages
EMP
DEPT
member
of staff
Works_in
1
Database Management
COP4540, SCS, FIU
Multiway relationship
Usually binary relationships (connecting two
E.S.) suffice.
However, there are some cases where three or
more E.S. must be connected by one
relationship.
Example: relationship among students,
courses, TA's.
Students
taking
N
N
Courses
assisting
1
TAs
Database Management
COP4540, SCS, FIU
Multiway relationship
What if students are divided into sections, each
headed by a TA?
A student would be related to only one of the TA's
for the course. Which one?
Students
M
N
Enrolls
1
TAs
Database Management
COP4540, SCS, FIU
Attributes on Relationships
price
Beers
Bars
sells
Bars
sells
Database Management
COP4540, SCS, FIU
price
Bars
Prices
Beers
The
Bar
The
Price
The
Beer
BBP
Database Management
COP4540, SCS, FIU
4-nary Relationship
SOLICITOR
BUYER
Arranges
FINANCIAL_
INSTITUTION
BID
A buyer, advised by a solicitor, and supported by a financial
institution, places a bid for a property.
A simultaneous relationship among four instances.
Database Management
COP4540, SCS, FIU