Database Systems ER Model - Lec 5
Database Systems ER Model - Lec 5
Computer Science
Components of ER Diagram
ER Model consists of Entities, Attributes, and Relationships among Entities
in a Database System.
Computer Science
Relationships in ERD
The association among entities is known as
relationship. Relationships are represented by the
diamond-shaped box. For example, an employee
works_at a department, a student enrolls in a
course. Here, Works_at and Enrolls are called
relationships.
Computer Science
Degree of a relationship set
The number of participating entities in a
relationship describes the degree of the
relationship. The three most common relationships
in E-R models are:
1. Unary (degree1)
2. Binary (degree2)
3. Ternary (degree3)
Computer Science
Degree of a relationship set
1. Unary relationship: This is also called
recursive relationships. It is a relationship
between the instances of one entity
type. For example, one person is married
to only one person.
Computer Science
Degree of a relationship set
Computer Science
Degree of a relationship set
3. Ternary relationship: It is a relationship amongst instances
of three entity types. In fig, the relationships "may have"
provide the association of three entities, i.e., TEACHER,
STUDENT, and SUBJECT. All three entities are many-to-many
participants. There may be one or many participants in a
ternary relationship.
Computer Science
Cardinality
Cardinality describes the number of entities in one entity set, which can be
associated with the number of entities of other sets via relationship set.
Types of Cardinalities
1. One to One: One entity from entity set A can be contained with at most
one entity of entity set B and vice versa. Let us assume that each student has
only one student ID, and each student ID is assigned to only one person. So,
the relationship will be one to one.
Computer Science
Cardinality
2. One to many: When a single instance of an entity is
associated with more than one instances of another
entity then it is called one to many relationships. For
example, a client can place many orders; a order
cannot be placed by many customers.
Computer Science
Cardinality
3. Many to One: More than one entity from entity set A
can be associated with at most one entity of entity set B,
however an entity from entity set B can be associated with
more than one entity from entity set A. For example - many
students can study in a single college, but a student cannot
study in many colleges at the same time.
Computer Science
Cardinality
4. Many to Many: One entity from A can be
associated with more than one entity from B and vice-
versa. For example, the student can be assigned to
many projects, and a project can be assigned to many
students.
Computer Science
Participation Constraints
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.
Computer Science
How to Draw ER Diagram?
1. The very first step is Identifying all the Entities, and place
them in a Rectangle, and labeling them accordingly.
2. The next step is to identify the relationship between them
and place them accordingly using the Diamond, and make
sure that, Relationships are not connected to each other.
3. Attach attributes to the entities properly.
4. Remove redundant entities and relationships.
5. Add proper colors to highlight the data present in the
database.
Computer Science
Q&A
What is the main purpose of an ER Diagram?
ER Diagrams are used to visually represent the structure of a database, showing entities, their attributes, and
relationships between them.
Computer Science