Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

Entity

Relationship
Diagram
ER Diagram
ENTITY RELATIONAL (ER) MODEL is a high-level conceptual data
model diagram.
• It’s a pictorial representation.

Why ER diagram
• ER modeling helps you to analyze data requirements systematically
to produce a well-designed database.
• The Entity-Relation model represents real-world entities and the
relationship between them.
• It is considered a best practice to complete ER modeling before
implementing your database.
Basic structure

● An Entity Relationship diagram is a visual representation of different


data using conventions that describe how these data are related to each
other.

● An entity can be a real-world object that can be easily identifiable.


Example: specific person, company, event, plant.

● An entity set is a set of entities of the same type that share the same
properties.
Example: set of all persons, companies, trees, holidays.
Basic structure

● An entity is represented by a set of attributes; i.e., descriptive


properties possessed by all members of an entity set.
Example:

instructor = (ID, name, street, city, salary )


course= (course_id, title, credits)

● A subset of the attributes form a primary key of the entity set;


which aids in uniquely identifying each member of the set.
Example: ID of instructor.
Entity Sets -- instructor and student

instructor_ID instructor_name student-ID student_name


Relationship Sets
• A relationship is an association among several entities

Example:
44553 (Peltier) advisor 22222 (Einstein)
student entity relationship set instructor entity

• A relationship set is a mathematical relation among n  2 entities, each taken


from entity sets

{(e1, e2, … en) | e1  E1, e2  E2, …, en  En}

where (e1, e2, …, en) is a relationship


– Example:
(44553,22222)  advisor
Relationship Set advisor
Basic structure
● Entities can be represented graphically as follows:
• Rectangles represent entity sets.
• Attributes are represented in ellipse.
• Underline indicates primary key attributes.

PHONE
ADDRESS NUMBER NAME

ID
PERSON
Types of Attributes

Simple attribute :- cannot be divided further Eg: Roll Number

Multivalued attribute :- More than one value possible


Eg: Phone number , Skills of a person

Composite attribute :- can be divided further Eg: Address ( street


lane , city , country ), Name ( First name , Last Name )

Derived attributes are the attributes that do not exist in the


physical database, but their values are derived from other
attributes present in the database Eg : age derived from DOB
Composite Multivalued
attribute attribute Simple
attribute
Phone_
address
number
Height

Street_
city Aadhar_no
_no

PERSON
Key
Derived attribute
DOB
age attribute
Relationship
• How to represent relationship between the entities ?

The association among entities


is called a relationship.
For example, an employee
Relationship works_at a department, a
student enrolls in a course.
Enrolls , works at are called
relationships

student enrolls course


RECURSIVE RELATIONSHIP

Recursive relationships superv


represent self-referencing ision
relationships.
supervisee supervisor

Employee
prerequisite

prereq_id Course_id

Course
Degree of Relationship:
• The number of participating entities in a relationship defines the
degree of the relationship.

• Binary = degree 2

Binary
• Ternary = degree 3

• n-ary = degree

student enrolls course


Ternary Relationship

Instructor
ternary

allot_
student grade course
N-ary relationship
Instructor
n-ary

student offers course

class_room

Note : Recursive Relationship degree is unary


Exercise 1
• A company has several departments. Each department has a
supervisor and at least one employee. Every supervisor has only one
department under him. Employees must be assigned to at least one,
but possibly more departments. At least one employee is assigned to
a project. Each employee is assigned atleast one project. The
important data fields are the names of the departments, projects,
supervisors and employees, as well as the supervisor and employee
number and a unique project number.
Identify Entities
• A company has several departments. Each department has a
supervisor and at least one employee. Every supervisor has only
one department under him. Employees must be assigned to at
least one, but possibly more departments. At least one employee
is assigned to a project. Each employee is assigned atleast one
project. The important data fields are the names of the
departments, projects, supervisors and employees, as well as the
supervisor and employee number and a unique project number.
Entities

project supervisor

Employee Department
Identify Attributes
• A company has several departments. Each department has
a supervisor and at least one employee. Every supervisor
has only one department under him. Employees must be
assigned to at least one, but possibly more departments. At
least one employee is assigned to a project. Each employee
is assigned atleast one project. The important data fields are
the names of the departments, projects, supervisors and
employees, as well as the supervisor and employee
number and a unique project number.
Attributes
S_id S_name
P_name P_no

project supervisor

Employee Department

E_id E_name D_id D_name


Identify relationship
• A company has several departments. Each department has
a supervisor and at least one employee. Every supervisor
has only one department under him. Employees must be
assigned to at least one, but possibly more departments.
At least one employee is assigned to a project. Each
employee is assigned atleast one project. The important data
fields are the names of the departments, projects,
supervisors and employees, as well as the supervisor and
employee number and a unique project number.
Attributes
S_id S_name
P_name P_no

project supervisor

assi ma
gne nag
d es

work
Employee s Department

E_id E_name D_id D_name


Exercise 2
UPS prides itself on having up-to-date information on the processing and
current location of each shipped item. To do this, UPS relies on a company-wide
information system. Shipped items are the heart of the UPS product tracking
information system. Shipped items can be characterized by item number
(unique), weight, dimensions, insurance amount, destination, and final delivery
date. Shipped items are received into the UPS system at a single retail center.
Retail centers are characterized by their type, uniqueID, and address. Shipped
items make their way to their destination via one or more standard UPS
transportation events (i.e., flights, truck deliveries). These transportation events
are characterized by a unique scheduleNumber, a type (e.g, flight, truck), and a
deliveryRoute. Please create an Entity Relationship diagram that captures this
information about the UPS system.
Thank you

You might also like