You are on page 1of 13

ER model

o ER model stands for an Entity-Relationship model. It is a high-level data model. This


model is used to define the data elements and relationship for a specified system.
o It develops a conceptual design for the database. It also develops a very simple and
easy to design view of data.
o In ER modeling, the database structure is portrayed as a diagram called an entity-
relationship diagram.

For example, Suppose we design a school database. In this database, the student will be
an entity with attributes like address, name, id, age, etc. The address can be another entity
with attributes like city, street name, pin code, etc and there will be a relationship between
them.

Component of ER Diagram
Entity, Entity Type, Entity Set –
An Entity may be an object with a physical existence – a particular person, car, house,
or employee – or it may be an object with a conceptual existence – a company, a job, or
a university course.
An Entity is an object of Entity Type and set of all entities is called as entity set. e.g.; E1
is an entity having Entity Type Student and set of all students is called Entity Set. In ER
diagram, Entity Type is represented as:
a. Weak Entity

An entity that depends on another entity called a weak entity. The weak entity doesn't
contain any key attribute of its own. The weak entity is represented by a double rectangle.
Attribute(s):
Attributes are the properties which define the entity type. For example, Roll_No,
Name, DOB, Age, Address, Mobile_No are the attributes which defines entity type
Student. In ER diagram, attribute is represented by an oval.

For example, id, age, contact number, name, etc. can be attributes of a student.

Key Attribute –
The attribute which uniquely identifies each entity in the entity set is called key attribute.For
example, Roll_No will be unique for each student. In ER diagram, key attribute is represented
by an oval with underlying lines.

Composite Attribute –
An attribute composed of many other attribute is called as composite attribute. For example,
Address attribute of student Entity type consists of Street, City, State, and Country. In ER
diagram, composite attribute is represented by an oval comprising of ovals.
Multivalued Attribute –
An attribute consisting more than one value for a given entity. For example, Phone_No (can be
more than one for a given student). In ER diagram, multivalued attribute is represented by
double oval.

Derived Attribute –
An attribute which can be derived from other attributes of the entity type is known as derived
attribute. e.g.; Age (can be derived from DOB). In ER diagram, derived attribute is represented
by dashed oval.

The complete entity type Student with its attributes can be represented as:
3. Relationship
A relationship is used to describe the relation between entities. Diamond or rhombus is used
to represent the relationship.

Types of relationship are as follows:

a. One-to-One Relationship

When only one instance of an entity is associated with the relationship, then it is known as
one to one relationship.

For example, A female can marry to one male, and a male can marry to one female.

b. One-to-many relationship

When only one instance of the entity on the left, and more than one instance of an entity on
the right associates with the relationship then this is known as a one-to-many relationship.
For example, Scientist can invent many inventions, but the invention is done by the only
specific scientist.

c. Many-to-one relationship

When more than one instance of the entity on the left, and only one instance of an entity on
the right associates with the relationship then it is known as a many-to-one relationship.

For example, Student enrolls for only one course, but a course can have many students.

d. Many-to-many relationship
When more than one instance of the entity on the left, and more than one instance of an
entity on the right associates with the relationship then it is known as a many-to-many
relationship.

For example, Employee can assign by many projects and project can have many
employees.

Participation Constraints
 Total Participation − each entity is involved in the relationship. Total participation
is represented by double lines.
 Partial participation − Not all entities are involved in the relationship. Partial
participation is represented by single lines.
Degree of a relationship set:
The number of different entity type participating in a relationship set is called as
degree of a relationship set.
1. Unary Relationship –
When there is only ONE entity set participating in a relation, the relationship is
called as unary relationship. For example, one person is married to only one
person.

2. Binary Relationship –
When there are TWO entities set participating in a relation, the relationship is
called as binary relationship. For example, Student is enrolled in Course.

3. n-ary Relationship –
When there are n entities set participating in a relation, the relationship is called
as n-ary relationship.
Cardinality: cardinality refers to the relationship between two tables. Relationship
can be of four types.
One to One – A single row of first table associates with single row of second
table. For example, a relationship between person and passport table is one to
one because a person can have only one passport and a passport can be
assigned to only one person.

One to Many – A single row of first table associates with more than one rows of
second table. For example, relationship between customer and order table is one
to many because a customer can place many orders but a order can be placed
by a single customer alone.
Many to One – Many rows of first table associate with a single row of second
table. For example, relationship between student and university is many to one
because a university can have many students but a student can only study only
in single university at a time.

Many to Many – Many rows of first table associate with many rows of second
table. For example, relationship between student and course table is many to
many because a student can take many courses at a time and a course can be
assigned to many students.

Notation of ER diagram
Database can be represented using the notations. In ER diagram, many notations are used
to express the cardinality. These notations are as follows:

You might also like