0% found this document useful (0 votes)
76 views70 pages

ER Diagram

The document discusses entity relationship (ER) diagrams. It defines an ER diagram as a type of flowchart that illustrates how entities such as objects or concepts relate to each other within a system. ER diagrams contain three basic components: entities, attributes, and relationships. Entities are represented by rectangles, attributes by ovals, and relationships by diamonds. ER diagrams help describe relationships between entities, allow building databases quickly, and help communicate a database's structure to users.

Uploaded by

Reemmoq 12
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)
76 views70 pages

ER Diagram

The document discusses entity relationship (ER) diagrams. It defines an ER diagram as a type of flowchart that illustrates how entities such as objects or concepts relate to each other within a system. ER diagrams contain three basic components: entities, attributes, and relationships. Entities are represented by rectangles, attributes by ovals, and relationships by diamonds. ER diagrams help describe relationships between entities, allow building databases quickly, and help communicate a database's structure to users.

Uploaded by

Reemmoq 12
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/ 70

By: Samira M.

Silmy
OUTLINE
• What is ER Diagram?

• Why use ER Diagram?

• The components of an ER diagram.

• ER Diagrams Symbols & Notations.

• Weak Entity sets.

• Cardinality.

• Participation.

• Exercises.
WHAT IS ER DIAGRAM?
• ER Diagram stands for Entity Relationship Diagram, also
known as ERD.

• It is a type of flowchart that illustrates how “entities” such


as people, objects or concepts relate to each other within a
system.
WHAT IS ER DIAGRAM?
• ER diagrams are created based on three basic concepts:
▪ Entities.
▪Attributes.
▪Relationships.
• ER Diagrams contain different symbols:

▪ Rectangles to represent entities.

▪ Ovals to define attributes.

▪ Diamond shapes to represent relationships.


OUTLINE
• What is ER Diagram?

• Why use ER Diagram?

• The components of an ER diagram.

• ER Diagrams Symbols & Notations.

• Weak Entity sets.

• Cardinality.

• Participation.

• Exercises.
WHY USE ER DIAGRAM?
• It helps to describe entities, attributes, relationships.
• It provide a preview of how all your tables should connect, what fields are
going to be on each table.
• ER diagrams are translatable into relational tables which allows you to build
databases quickly.
• The database designer gains a better understanding of the information to
be contained in the database with the help of ER diagram.
• ER Diagram allows you to communicate with the logical structure of the
database to users.
OUTLINE
• What is ER Diagram?

• Why use ER Diagram?

• The components of an ER diagram.

• ER Diagrams Symbols & Notations.

• Weak Entity sets.

• Cardinality.

• Participation.

• Exercises.
THE COMPONENTS OF AN ER DIAGRAM

• ER diagrams are created based on three basic concepts:


▪ Entities.

▪ Attributes.

▪ Relationships.
THE COMPONENTS OF AN ER DIAGRAM: ENTITIES

Entity
• A definable thing—such as a person, place, object, concept or event—that
can have data stored about it.
• Every entity is made up of some ‘attributes’ which represent that entity.
• Think of entities as nouns
• Typically shown as a rectangle.

Examples of entities:
• Person: Employee, Student, Patient.
• Place: Store, Building.
• Object: Machine, product, and Car.
• Event: Sale, Registration, Renewal.
• Concept: Account, Course.
THE COMPONENTS OF AN ER DIAGRAM: ENTITIES

Entity type:
• A group of definable things, such as students or athletes,
whereas the entity would be the specific student or athlete.
• Other examples: customers, cars or products.

Entity set:
• Same as an entity type, but defined at a particular point in time,
such as students enrolled in a class on the first day.
• An entity set is a group of similar kind of entities.
• Other examples:
• Customers who purchased last month.
• Cars currently registered in Florida.
THE COMPONENTS OF AN ER DIAGRAM: ENTITIES

Entity categories: Entities are categorized as strong, weak or associative.


• A strong entity can be defined only by its own attributes.
• A weak entity is a type of entity which doesn’t have its key attribute. It
can be identified uniquely by considering the primary key of another
entity.
• An associative entity associates entities (or elements) within an entity
set.

Or strong Entity
EXERCISE

pick out the entities

A university consists of a number of departments.


Each department offers several courses. A number of
modules make up each course. Students enroll in a
particular course and take modules towards the
completion of that course. Each module is taught by a
lecturer from the appropriate department, and each
lecturer tutors a group of students.
pick out the entities

A university consists of a number of departments.


Each department offers several courses. A number of
modules make up each course. Students enroll in a
particular course and take modules towards the
completion of that course. Each module is taught by a
lecturer from the appropriate department, and each
lecturer tutors a group of students.
THE COMPONENTS OF AN ER DIAGRAM: RELATIONSHIP

Relationship
• It defines the interconnection between two entities.
• Relationship is nothing but an association among two or more entities.
• Typically shown as a diamonds.
• Entities take part in relationships.
• Think of relationships as verbs.
• There are two specific types of relationships:
▪ Strong relationship.
▪ Weak relationship.
THE COMPONENTS OF AN ER DIAGRAM: RELATIONSHIP

There are two specific types of relationships:


1.Strong relationship:
• When entity A connected with a strong relationship to entity B, the
existence of entity A is independent of the existence of entity B.

• It Is depicted as a diamond with a normal line border.


THE COMPONENTS OF AN ER DIAGRAM: RELATIONSHIP

2. Weak relationship:
• When entity A connected with a weak relationship to entity B, the
existence of entity A depends on B entity existence.

• It is depicted as a diamond with a double line border.


THE COMPONENTS OF AN ER DIAGRAM: RELATIONSHIP

Examples of Relationships:
• You are attending this lecture → A student attends a lecture.

Attends
Students Lecture
/takes

• I am giving the lecture → A lecturer is giving a lecture.

Is
Lecturer Lecture
giving
THE COMPONENTS OF AN ER DIAGRAM: RELATIONSHIP

Examples of Relationships:

• A customer is borrowing a loan.

Customer borrower loan

• An employee works on a branch.

Employee worksOn Branch


THE COMPONENTS OF AN ER DIAGRAM: RELATIONSHIP

▪ An attribute can also be associated with a relationship set.


▪ For instance the advisor relationship set between entity sets instructor and
student may have the attribute date which tracks when the student started
being associated with the advisor.

76766 Crick 98988 Tanaka


45565 Katz 3 May 2008 12345 Shankar
10 June 2007
10101 Srinivasan 00128 Zhang
12 June 2006

98345 Kim 6 June 2009 76543 Brown


76543 Singh 30 June 2007
76653 Aoi
31 May 2007
22222 Einstein 23121 Chavez
4 May 2006

instructor 44553 Peltier

student
descriptive attributes Undivided rectangle. with a dashed line
EXERCISE

pick out the relationships

A university consists of a number of departments.


Each department offers several courses. A number of
modules make up each course. Students enroll in a
particular course and take modules towards the
completion of that course. Each module is taught by a
lecturer from the appropriate department, and each
lecturer tutors a group of students.
pick out the relationships

A university consists of a number of departments.


Each department offers several courses. A number of
modules make up each course. Students enroll in a
particular course and take modules towards the
completion of that course. Each module is taught by a
lecturer from the appropriate department, and each
lecturer tutors a group of students.
Drawing an ER Diagram Steps

Step 1) Entity Identification.


Step 2) Relationship Identification.
Step 3) Cardinality Identification.
Step 4) Identify Attributes.
pick out the relationships

A university consists of a number of departments.


Each department offers several courses. A number of
modules make up each course. Students enroll in a
particular course and take modules towards the
completion of that course. Each module is taught by a
lecturer from the appropriate department, and each
lecturer tutors a group of students.
forming the relationships among the entities

A university consists of a number of departments.


• Each department offers several courses.
• A number of modules make up each course.
• Students enroll in a particular course and take modules towards
the completion of that course.
• Each module is taught by a lecturer
• a lecturer from the appropriate department,
• and each lecturer tutors a group of students.
Drawing the diagram
Entities: departments, courses, modules, students, lecturer

department

course module
lecturer

student
Each department offers several courses.
offers department

course module
lecturer

student
A number of modules make up each course.
offers department

course include module


lecturer

student
Students enroll in a particular course
offers department

course include module


lecturer

enroll in
student
Students enroll in a particular course and take
modules towards the completion of that course

offers department

course include module


lecturer

takes

enroll in
student
Each module is taught by a lecturer

offers department

course include module teaches lecturer

takes

enroll in
student
a lecturer from the appropriate department

offers department employs

course include module teaches lecturer

takes

enroll in
student
and each lecturer tutors a group of students

offers department employs

course include module teaches lecturer

takes

enroll in tutors
student
THE COMPONENTS OF AN ER DIAGRAM: ATTRIBUTES

Attributes
• A property or characteristic of an entity.
• Typically shown as a an oval or circle.
• For example, a lecture might have attributes: time, date, duration, place, etc.

LecturerID
time

date
lecture
duration

place
THE COMPONENTS OF AN ER DIAGRAM: ATTRIBUTES
THE COMPONENTS OF AN ER DIAGRAM: ATTRIBUTES
OUTLINE
• What is ER Diagram?

• Why use ER Diagram?

• The components of an ER diagram.

• ER Diagrams Symbols & Notations.

• Weak Entity sets.

• Cardinality.

• Participation.

• Exercises.
ER DIAGRAMS SYMBOLS & NOTATIONS

• ER Diagram is a visual representation of data that describes how


data is related to each other using different ERD Symbols and
Notations.
• Symbols and Notations are used to represent relationships
between elements, entities and attributes.

• Entity Relationship Diagram Symbols & Notations mainly contains


three basic symbols which are rectangle, oval and diamond.
• There are some sub-elements which are based on main elements in
ERD Diagram.
ER DIAGRAMS SYMBOLS & NOTATIONS

• Entity Relationship Diagram Symbols & Notations mainly contains


three basic symbols: which are rectangle, oval and diamond.

Or strong Entity
ER DIAGRAMS SYMBOLS & NOTATIONS
• There are some sub-elements which are based on main elements in
ERD Diagram.

Or strong Entity
ER DIAGRAMS SYMBOLS &
NOTATIONS
OUTLINE
• What is ER Diagram?

• Why use ER Diagram?

• The components of an ER diagram.

• ER Diagrams Symbols & Notations.

• Weak Entity sets.

• Cardinality.

• Participation.

• Exercises.
Choice of Primary key for Binary
Relationship
▪ Many-to-Many relationships. The preceding union of the primary
is chosen as the primary key.

▪ One-to-Many relationships . The primary key of the “Many” side is


a is used as the primary key.

▪ Many-to-one relationships. The primary key of the “Many” side is


used as the primary key.

▪ One-to-one relationships. The primary key of either one of the


participating entity sets forms can be chosen as the primary key.
THE COMPONENTS OF AN ER DIAGRAM: ENTITIES
Entity categories: Weak Entity

sec_course
THE COMPONENTS OF AN ER DIAGRAM: ENTITIES
Entity categories: Weak Entity

• is a type of entity that does not have any unique key for the
attribute tuples.

• A weak entity depends on another entity, that is considered


its owner, called its identifying entity.

• It is depicted as a rectangle with a double border.


THE COMPONENTS OF AN ER DIAGRAM: ENTITIES
Entity categories: Weak Entity

• Instead of associating a primary key with a weak entity, we


use the identifying entity, along with extra attributes called
discriminator (partial key) to uniquely identify a weak entity.

• The primary key of a weak entity set is formed by the primary


key of the strong entity set on which the weak entity set is
existence dependent, plus the weak entity set’s discriminator.
OUTLINE
• What is ER Diagram?

• Why use ER Diagram?

• The components of an ER diagram.

• ER Diagrams Symbols & Notations.

• Weak Entity sets.

• Cardinality.

• Participation.

• Exercises.
CARDINALITY
• Cardinality is the degree of relationship.
• It is represented by characters “1”, “N” or “M” usually
placed at the ends of the relationships.

• Different types of cardinal relationships are:


• One-to-One Relationships (1:1).
• One-to-Many Relationships (1:N).
• May to One Relationships (N:1).
• Many-to-Many Relationships (M:N).
CARDINALITY
•Types of cardinal relationships:
1. One-to-One Relationships (1:1).
The employee can manage only one department, and each
department can be managed by one employee only.
CARDINALITY
Types of cardinal relationships:
1. One-to-One Relationships (1:1).
A student is associated with at most one instructor via the
relationship advisor

Instructor advisor Student


CARDINALITY
•Types of cardinal relationships:
2. One-to-Many Relationships (1:N).
The customer may place many orders, but each order can be
placed by one customer only:
CARDINALITY
•Types of cardinal relationships:
2. One-to-Many Relationships (1:N).
▪ an instructor is associated with several (including 0) students via
advisor
▪ a student is associated with at most one instructor via advisor.

1 N
Instructor advisor Student
CARDINALITY
•Types of cardinal relationships:
3. Many-to-One Relationships (N:1).
Many employees may belong to one department, but one particular employee
can belong to one department only:
CARDINALITY
•Types of cardinal relationships:
3. Many-to-One Relationships (N:1).
▪ An instructor is associated with at most one student via advisor.
▪ A student is associated with several (including 0) instructors via advisor.

N 1
Instructor advisor Student
CARDINALITY
•Types of cardinal relationships:
4. Many-to-Many Relationships (M:N).
▪ One student may belong to more than one student organizations,
and one organization can admit more than one student:
CARDINALITY
•Types of cardinal relationships:
4. Many-to-Many Relationships (M:N).
▪ An instructor is associated with several (possibly 0) students via
advisor.
▪ A student is associated with several (possibly 0) instructors via
advisor.

M N
Instructor advisor Student
OUTLINE
• What is ER Diagram?

• Why use ER Diagram?

• The components of an ER diagram.

• ER Diagrams Symbols & Notations.

• Weak Entity sets.

• Cardinality.

• Participation.

• Exercises.
PARTICIPATION

• Total participation - In the Chen notation, this kind of relation is


depicted as a double line.

• Partial participation - In the Chen notation, a partial participation is


represented by a single line.

• Optional participation In the Chen notation, a optional participation


is represented by dashed line.
PARTICIPATION
•Total participation means that every entity in the set is involved in
the relationship.
▪ e.g., each student must be guided by a professor (there are no
students who are not guided by any professor).

•Partial participation means that not all entities in the set are involved
in the relationship.
▪ e.g., not every professor guides a student (there are professors
who don’t).
OUTLINE
• What is ER Diagram?

• Why use ER Diagram?

• The components of an ER diagram.

• ER Diagrams Symbols & Notations.

• Weak Entity sets.

• Cardinality.

• Participation.

• Exercises.
EXERCISES

For a bank: A customer can be a borrower for at most one loan. A loan is
associated with at most one borrower customer.

Customer borrower Loan


EXERCISES

For a bank: A customer can be a borrower several loan. A loan is associated


with at most one borrower customer.

1 N
Customer borrower Loan
EXERCISES

For a bank: A customer can be a borrower several loan. A loan is associated


with one or more customers .

M N
Customer borrower Loan
EXERCISES

For a bank: A customer can be a borrower zero to several loan . A loan is


must associated with one or more customers.

M N
Customer borrower Loan
Construct an E-R diagram for a car
insurance company whose customers own one or
more cars each. Each car has associated with it zero
to any number of recorded accidents.

customer owns car

accident participated
THANK YOU

You might also like