0% found this document useful (0 votes)
21 views14 pages

Database Systems ER Model - Lec 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views14 pages

Database Systems ER Model - Lec 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Database Systems

Entity Relationship Model


Part B

Dr. Waheed Anwar

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.

Example Teacher teaches students. Here teaches is


relationship.

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

2. Binary relationship: It is a relationship


between the instances of two entity
types. For example, the Teacher teaches
the subject.

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.

Using Sets, it can be represented as:

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.

Using Sets, it can be represented as:

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.

Using Sets, it can be represented as:

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.

Using Sets, it can be represented as:

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.

How do ER Diagrams help in database design?


They simplify the process of mapping out the database structure, making it easier to organize data and
understand how different entities interact.

What is the difference between a Weak Entity and a Strong Entity?


A Strong Entity has a unique identifier or primary key, while a Weak Entity lacks a primary key and relies on a
Strong Entity for identification.

Can ER Diagrams represent complex data relationships?


Yes, ER Diagrams can model complex relationships, including one-to-one, one-to-many, and many-to-many
relationships.

Why are Participation Constraints used in ER Diagrams?


Participation Constraints indicate whether all entities must participate in a relationship or if only some may do
so, helping to accurately represent real-world scenarios.

Computer Science

You might also like