Lecture 7
Lecture 7
Lecture # 7
By
Maria Gul
1
Entity Relationship Model
• Entity Relationship model is a logical
representation of data in an organization.
• It views the entire system as a collection of
entities related to one another.
• It is used to describe the elements of a
system and their relationships.
• It was introduced by Peter Chen in 1976.
• It develops a conceptual design for the
database.
• It also develops a very simple and easy to
design view of data.
2
Components of ER Model
1. Entities
• An entity is a person , place, thing or event
for which data is collected and maintained.
• In the ER diagram, an entity can be
represented as rectangles.
• For Example, a library system may contain
data about different entities like BOOK and
MEMBER.
• A college system may include entities like
STUDENT, TEACHER, and CLASS.
3
Components of ER Model
1. Entities
• E.g., we have two entities Student and
College and these two entities have many to
one relationship as many students study in a
single college.
4
Components of ER Model
1. Entities
• Entity is used in three different meanings
that are as follows:
a. Entity Type
• A set of entities with same attributes is
called entity type.
• All entities in an entity type share common
characteristics.
• It is known as entity class.
• E.g., STUDENT entity class is a set of all
students.
5
Components of ER Model
1. Entities
• Entity is used in three different meanings
that are as follows:
b. Entity Instance
• A member of an entity class is known as an
entity instance.
• It is also known as entity occurrence.
• Each entity instance of an entity type has its
own value for each instance.
• e.g., a student Ahmed of STUDENT entity
type is an entity instance.
6
Components of ER Model
Entity Instance
For example, there is one EMPLOYEE entity type in
most organizations, but there may be hundreds (or
even thousands) of instances of this entity type
stored in the database.
7
Components of ER Model Entity
Entity Instance Entity Type Instance
Properties of
Entity Type Entity
Instance 8
Difference between Entity Type and Entity Instance
9
Components of ER Model
1. Entities
• Entity is used in three different meanings
that are as follows:
c. Entity Set
• A set of all entities of a particular entity type
in the database at a given point of time is
called entity set.
• E.g., an entity set Student may consist of all
students in the university.
10
Components of ER Model Entity Set
Entity Set Entity Type
Properties of
Entity Type
11
Components of ER Model
1. Entities
Types of Entity
1. Weak Entity Type
• An entity type whose existence depends on
some other entity type.
• An entity type whose instances cannot exist
without being linked with the instances of
some other entity types.
12
Components of ER Model
1. Entities
Types of Entity
1. Weak Entity Type
• A weak entity type has no business meaning
in an E-R diagram without the entity on
which it depends.
• They cannot exist independently.
• It has a partial identifiers.
• It is also called child, dependent or
subordinate entity.
13
Components of ER Model
Representation of Weak Entity
• A double rectangle is used for representing a weak
entity set.
• The double diamond symbol is used for
representing the relationship between a strong
entity and weak entity which is known as
identifying relationship.
14
Components of ER Model
Representation of Weak Entity
• Double lines are used for presenting
the connection with a weak entity set with
relationship.
• Simply a weak entity is nothing but an entity
which does not have a primary key attribute.
Weak Entity
15
Components of ER Model
• As weak entity does not has any key attribute but
we need some attribute which along with the
primary key of the dominant entity allows the
subordinate entity to be identified uniquely. This
attribute is called the discriminator of the weak
entity. It is also called as the partial key.
16
Components of ER Model
Weak Entity Type-Example
• We want to store the data of a student after
assigning a class to him. It means data cannot be
stored if CLASS entity does not exist. In order to
store record of the student, we first need to create
an entity that represents a class.
• Here, STUDENT is a weak entity because it depends
upon CLASS entity.
17
Components of ER Model
2. Strong Entity Type
• An entity type that exists independently of other
entity types.
• An entity type whose instances can exist
independently.
• The entity type have there own identity.
• It always have a identifier.
• It is also called Identifying owner.
• It is also called parent, owner or dominant entity.
• In previous example, CLASS is strong entity.
18
Components of ER Model
Representation of Strong Entity
• The strong entity is represented by a single
rectangle.
• Relationship between two strong entities is
represented by a single diamond.
• The primary key of the strong entity is represented
by underlining it
Strong Entity
19
Components of ER Model
Identifying Relationship
The relationship between a weak entity type and
strong entity type is called an ‘identifying
relationship’ and shown with a double outlined
diamond instead of a single outlined diamond.
20
Components of ER Model
21
Example 2: Suppose we have two entity type EMPLOYEES and DEPENDANT
(children of the employee). The EMPLOYEE entity has attributes as
Emp_id, Emp_name, Job_title, Age, Salary, Address. And, the DEPENDANT
has attributes as Name, Age and Relation. So, Emp_id is the key attribute
of the EMPLOYEES entity type. So, EMPLOYEES is a strong entity and
DEPENDANT is a weak entity. The discriminator or the partial key for the
weak entity here is the ‘name’ attribute. This partial key along with the
key attribute of the EMPLOYEE helps in identifying each DEPENDANT
entity uniquely. Also, each and every DEPENDANT entity is related to one
of the EMPLOYEE entity. All the EMPLOYEE entity may not be related to
one or the other DEPENDANT entity but all the DEPENDANT entity is
related to one or the other EMPLOYEE entity. This is called total
participation. The strong entity EMPLOYEE is used to identify the weak
entity DEPENDANT. So, there is a relationship between these two entity
type. This relationship is called an identifying relationship. The above
relationship can be represented by the E-R diagram in the following way.
22
Components of ER Model
23
Components of ER Model
Identifying
Identifier Relationship
Strong
Weak
Entity Type
Entity Type
24
Components of ER Model
3. Associative Entity
• Is a type of entity that associates the instances of
one or many entity types with one another.
• Attributes of the associative represent the
relationship between the entity instances.
25
Components of ER Model
3. Associative Entity
Date
Name
26
Components of ER Model
3. Relationships
• A relationship is a logical connection
between different entities.
• Entities that participate in a relationship is
called participants.
• Relationship may be between different
entities or between an entity and itself.
27