Entity Relationship ER Model
Entity Relationship ER Model
Topperworld.in
ER Model
©Topperworld
DBMS
❖ Entity
An entity may be any object, class, person or place. In the ER diagram, an entity
can be represented as rectangles.
1. Strong entity: This type of entity has a primary key attribute which
uniquely identifies each record in a table. In the ER diagram, a strong
entity is usually represented by a single rectangle.
2. Weak entity: An entity does not have a primary key attribute and
depends on another strong entity via foreign key attribute. In the ER
diagram, a weak entity is usually represented by a double rectangle.
©Topperworld
DBMS
❖ Attribute
For example, id, age, contact number, name, etc. can be attributes of a student.
©Topperworld
DBMS
For example, the Name attribute of an employee entity type consists of First
name, Second name, and Last name.
©Topperworld
DBMS
For example, an employee can have more than one mobile number and email
address.
©Topperworld
DBMS
❖ Relationship
• A relationship in Entity-Relationship Model is used to describe the relation
between two or more entities.
• It is represented by a diamond shape in the ER diagram.
For example, student study in college, employee works in a department. Here,
‘study in’ and ‘works in’ are the relationships.
Degree of Relationship
A relationship where a number of different entity set participate is called as
degree of a relationship.
Degree of relationship can be categorized into the following types:
1. Unary Relationship
2. Binary Relationship
3. Ternary Relationship
4. n-ary Relationship
©Topperworld
DBMS
©Topperworld
DBMS
©Topperworld
DBMS
❖ Notation of ER diagram
❖ ER Design Issues
©Topperworld
DBMS
✓ The use of an entity set or attribute depends on the structure of the real-
world enterprise that is being modelled and the semantics associated
with its attributes.
✓ It leads to a mistake when the user use the primary key of an entity set
as an attribute of another entity set.
✓ Instead, he should use the relationship to do so.
✓ Also, the primary key attributes are implicit in the relationship set, but
we designate it in the relationship sets.
©Topperworld
DBMS
©Topperworld
DBMS
1. Fan Traps
2. Chasm Traps
Both Fan and Chasm traps occur when it becomes impossible to retrieve all the
necessary information needed from the entire diagram.
©Topperworld
DBMS
1) Fan Traps
©Topperworld
DBMS
2) Chasm Traps
A chasm trap is another problem with the ER model, which occurs when a
pathway does not exist in all the related entities. A chasm trap may exist where
there are one or more relationships with a minimum multiplicity of zero forming
part of the pathway between related entities.
A problem arises when we want to know which lockers are available in a branch.
Here, we consider an example of a bank where a single branch has one or more
©Topperworld
DBMS
customers who avail zero or more lockers to keep their belongings. We also
assume that a customer uses not all customers avail locker and not all lockers.
Now let us examine some occurrences of the relationships using a value for the
primary key attributes of Bank_branch, Customer, and Locker entities to
understand the problem more clearly.
Suppose we want to know which bank's branch locker L212 is available. We will
be unable to find the answer as locker L212 has not yet been allocated. The
inability to answer these questions is a result of a chasm trap. It would be
considered a loss of information.
To solve this problem, we need to identify the missing relationship that relates
the bank_branch entity with the locker entity it offers. This ensures that all the
times the lockers associated with each bank_branch are known, including those
lockers that have yet not been allocated.
©Topperworld
DBMS
Now let us examine the occurrences of the relationships using the values for the
primary key attribute of the given entities.
©Topperworld