Introduction of ER Model
Introduction of ER Model
Model
Definition
• The Entity-Relationship Model (ER Model) is a conceptual model for
designing a databases. This model represents the logical structure of a
database, including entities, their attributes and relationships between
them.
• Entity: An objects that is stored as data such
as Student, Course or Company.
• Gather the requirements (functional and data) by asking questions to the database users.
• Create a logical or conceptual design of the database. This is where ER model plays a
role. It is the most used graphical representation of the conceptual design of a database.
• After this, focus on Physical Database Design (like indexing) and external design (like
views)
Why Use ER Diagrams In DBMS?
• ER diagrams represent the E-R model in a database, making them easy
to convert into relations (tables).
• Lines: Lines represent attributes to entities and entity sets with other relationship types.
• Double Ellipse: Double ellipses represent multi-valued Attributes, such as a student's multiple
phone numbers
• Double Rectangle: Represents weak entities, which depend on other entities for identification.
Symbols Used in ER Model
What is an Entity?
• A Strong Entity is a type of entity that has a key Attribute that can uniquely
identify each instance of the entity. A Strong Entity does not depend on any
other Entity in the Schema for its identification. It has a primary key that
ensures its uniqueness and is represented by a rectangle in an ER diagram.
2. Weak Entity
• Attributes are the properties that define the entity type. For example,
for a Student entity Roll_No, Name, DOB, Age, Address, and
Mobile_No are the attributes that define entity type Student. In ER
diagram, the attribute is represented by an oval.
Attribute
Types of Attributes
1. Key Attribute
The attribute which uniquely identifies each entity in the entity set is
called the key attribute. For example, Roll_No will be unique for each
student. In ER diagram, the key attribute is represented by an oval
with an underline.
Key Attribute
2. Composite Attribute
Composite Attribute
3. Multivalued Attribute
An attribute consisting of more than one value for a given entity. For
example, Phone_No (can be more than one for a given student). In ER
diagram, a multivalued attribute is represented by a double oval.
Multivalued Attribute
4. Derived Attribute
An attribute that can be derived from other attributes of the entity type
is known as a derived attribute. e.g.; Age (can be derived from DOB).
In ER diagram, the derived attribute is represented by a dashed oval.
Derived Attribute
• The Complete Entity Type Student with its Attributes can
be represented as:
Entity-Relationship Set
Example
A set of relationships of the same type is known as a
relationship set. The following relationship set depicts
S1 as enrolled in C2, S2 as enrolled in C1, and S3 as
registered in C3.
Relationship Set
Degree of a Relationship Set
Binary Relationship
3. Ternary Relationship: When there are three entity
sets participating in a relationship, the relationship is
called a ternary relationship.
• 4. N-ary Relationship: When there are n entities set
participating in a relationship, the relationship is called
an n-ary relationship.
Ternary N-ary
Cardinality in ER Model
The maximum number of times an entity of an entity set
participates in a relationship set is known as cardinality.
Cardinality can be of different types:
1. One-to-One
When each entity in each entity set can take part only
once in the relationship, the cardinality is one-to-one.
Let us assume that a male can marry one female and a
female can marry one male. So the relationship will be
one-to-one.
• Using Sets, it can be represented as:
When entities in one entity set can take part only once in the
relationship set and entities in other entity sets can take part more
than once in the relationship set, cardinality is many to one.
• Let us assume that a student can take only one course but one
course can be taken by many students. So the cardinality will be n
to 1. It means that for one course there can be n students but for
one student, there will be only one course.
many to one cardinality
1. Total Participation: Each entity in the entity set must participate in the relationship. If
each student must enroll in a course, the participation of students will be total. Total
participation is shown by a double line in the ER diagram.
• 2. Partial Participation: The entity in the entity set may or may NOT participate in the
relationship. If some courses are not enrolled by any of the students, the participation in the
course will be partial.
The diagram depicts the ‘Enrolled in’ relationship set with Student Entity set having total
participation and Course Entity set having partial participation.
The diagram depicts the ‘Enrolled in’ relationship set with Student
Entity set having total participation and Course Entity set having
partial participation.