Вы находитесь на странице: 1из 12

ER Model : Introduction

 ER Model is and Entity Relationship Model. It means, a model which is used to


describe and define overall structure of any database by using schematic and
diagrammatic representation. ER Model defines the logic of database.
 The schematic and diagrammatic representation is generated using certain
components including entity, attributes, relationships etc. These components are
discussed in the next section.
ER Model : Components
 The components of entity relationship model are the building blocks which helps
in the generation of an ER Model diagram, which finally results in the design of
logical structure of a database. There are three basic components of Entity
Relationship Model. These are discussed below.
 All these components have definite diagrammatically representations which are
used for generation of ER Diagram. Let’s discuss them in detail now.

ER Model : Components

1. Entity

 An entity can be called as the basic object which represents the ER Model. It can
be a real world object/thing present physically or can be an object/thing present
logically/virtually. Entities are the objects or things or articles or pieces that have
a existence without any dependence on any other object.
For example : Bank account can be an entity, Loan can be an entity, Bank branch
can be an entity etc. These entities have their own properties which are known as
attributes.
STUDENT

ID Name AGE
1 Ahamd 12
2 Ali 13

Above is an example of a table called Student having 2 rows (1,Ahmad,12) and (2,Ali,13) .
Using this we can understand the difference.

Entity
It is something which has real existence. Like tuple1 contains information about Ahmadid,
name and Age) which has existence in real world . So the tuple1 is an entity. So we may
say each tuple is an entity.

Entity Type
It is collection of entity having common attribute. As in Student table each row is an entity
and have common attributes. So STUDENT is an entity type which contains entities having
attributes id, name and Age.Also each entity type in a database is described by a name and
a list of attribute.So we may say a table is an entity type
Entity SET
It is a set of entities of same entity type. so a set of one or more entities of Student Entity
type is an Entity Set.

2. Attribute

 Once the entities are defined, their properties support them and are known
as the attributes. These attributes also consists of specific values
corresponding to the type of entity they are related with. Attributes
describes the properties and characteristics of the entity.
For example : Attributes of Bank account (Which is an entity) can be “ Account
No, Account Holder Name, Balance etc.”. Also, values of attributes are domain
specific. It means, if account is an entity then balance cannot be negative. There
exists six types of attributes for specific types of entities.
a) Simple Attribute : Simple attribute are those attributes which cannot be divided
further because of their atomic nature.
Let’s make it clear with an example. The Account number of a customer can be a
simple attribute as it cannot be divided further. Date of birth of a person is
another example of simple attribute.
b) Composite Attribute : Composite attributes are those attributes which are the
combination of two or more than two simple attributes joined together.
For example : Name of a customer of account holder can be a composite
attribute.
Hafiz + waleed + khalid → First Name + Middle Name + Last Name {Composite
Attributes}
c) Derived Attribute : Derived Attributes are those attributes whose values are
derived from the already stored attributes in the database.
For example : Database consisting of height of a class. Then value of average
height can be derived from the already available data of students.
d) Single Valued Attribute : Single valued attribute are those which contains only
a single specified value or a single unique value.
For example : Nic Number, SSN No etc.
e) Multi Valued Attribute : Multi-valued attributes are those which can have
multiple value against them.
For example : Address, email, Phone number are multi-valued attributes.
f) Null Value Attribute : Null value attributes are those which can be left blank
without passing any value.
For example : A person can have a name without middle name and hence middle
name field can be left blank or null.
Waleed + khalid → First Name + _______ + Last Name

3. Relationship

 Relationship is the third and last component of the ER Model. It is


responsible for establishing a link of commuation between attributes and
entities as per requirements.
 For example : “Has an” can be termed as a relationship between a
customer and an account in bank.

ER Model : Relationship

 Relationship can be categorized into three majors :


o Binary Relationship : When any relationship is established among 2
entities, it is called binary relationship.
o Ternary Relationship : When any relationship is established among 3
entities, it is called ternary relationship.
o n-Degree Relationship : When any relationship is established among
any number of entities(2 or more than two), then n is replaced with
that number. For example : 2-Degree, 3-Degree, 4-Degree etc.

ER Diagram : Introduction
 An Entity Relationship Model is generated through ER Diagram i.e. known
as Entity Relationship Diagram which constitutes of various symbols with
the help of which entities, attributes and relationships are represented
diagrammatically. Each of these components has a separate notation. Let’s
discuss them together.
1. Entity : The entity is denoted through a rectangle. These rectangles are named
according to the names of entities.

ER Diagram : Entity

For example : Let the entities be Company, Course, Class and Loan. Then they
will be represented as :

Entity Example

2. Weak Entity : When attributes of an entity are not capable of determining the
entity uniquely, it is called as weak entity. Weak entity is denoted through a
double rectangle.

ER Diagram : Weak Entity

For example : In a bank, bank branch can be deduced as a weak entity as its
attributes are not enough to determine it uniquely.
Weak Entity Example

3. Relationship : The relationship in an Entity Relationship Diagram is denoted


through a diamond.

ER Diagram : Relationship

For example : A person works in a company can be described using a


relationship as :

Relationship Example
4. Attributes : Attributes in Entity Relationship Diagram are denoted through an
ellipse.

ER Diagram : Attribute

For example : A university acting as an entity can have multiple attributes as


name, location, courses, colleges etc.

Attribute Example

5. Key Attribute : Key attribute is a type of attribute which alone can determine
the entity uniquely. These are denoted through an ellipse with underline.

ER Diagram : Key Attribute

For example : A bank customer can be uniquely identified through his/her


account number.
Key Attribute Example

6. Multi valued Attribute : Multi valued attributes in Entity Relationship Diagram


are denoted through double ellipse.

ER Diagram : Multi Valued Attribute

For example : An account holding customer of bank can have multiple emails,
multiple mobile numbers and even multiple addresses(Permanent and
Corresponding). They can be termed as multi valued attributes.

Multi Valued Attribute Example


7. Composite Attributes : Composite attributes in Entity Relationship Diagram are
denoted by linked ellipse.

ER Diagram : Composite Attribute

For example : Consider the name of a person(First Name + Middle Name + Last
Name).

Composite Attribute Example

8. Derived Attribute : Derived attributes in Entity Relationship Diagram are


represented using dashed ellipse.

ER Diagram : Derived Attribute


For example : Consider a class having some students. Each of them can have
their name, address and age. We can derive the average age of the student from
already present data in the database.

Derived Attribute Example

9. Total Participation of Entity in Relation : In this type, every entity is fully


involved and linked in the relationship and this participation is denoted using
double lines.

Total Participation

10. Partial Participation of Entity in Relation : As the name suggests, some of the
entities participates in the relation fully and some of them participates partially.
Partial relation is denoted using single line.
Partial Participation

Extended Features Of ER Model :


Specialization & Generalization
 The Specialization and Generalization concept comes under the topic of
extended features of the Entity Relationship Model.
 These extended features of the entity relationship model are based upon
the conceptual hierarchy i.e. The manner in which ER Diagram is
generated, view of that ER Diagram is termed as either the specialization or
generalization. The topic still not clear yet? Check below the easier
definition and diagram below.

Extended Features : Specialization & Generalization


1. Specialization

 Specialization in general terms, is a process of mastering a specific


domain. But, with respect to ER Model, specialization is the procedure to
split up the entities into further sub entities on the basis of their
functionalities, specialities and features. This process is a Top-to-Down
approach.
 For example : In a database of hospital, a person can either be a doctor,
staff or patient which can be spirited according to their functions
and specialties.

Specialization : Example

2. Generalization

 Generalization is the reverse process of specialization. In generalization,


the sub entities are combined together into a super entity set on the basis
of some common features in such a way that the new entity thus formed
contains all the features of the sub entities. Generalization is a Bottom-to-
Up approach.
 For example : Goat, Lion and Monkey have some come traits and they all
together can be combined in class of animals.
Generalization: Example

Aggregation : Concept

 ER Model is a way which helps in database design with utmost efficiency.


However, it does possess some limitations. One of the major limitations of
ER Model is its inability to represent relationship among relationship. In
order to represent ternary relationship, it can be represented using ER
Model but a lot of redundancies will arise. Hence, the concept of
aggregation is used to remove these redundancies.

Вам также может понравиться