Anda di halaman 1dari 17

Entity Relationship Diagram

Rani Mohanlal
Assistant Professor
Dept. of CSE
VAST

Table of Contents
Introduction
ERD components

Entity
Attribute
Relationship
Cardinality constraints
One - to - one
One - to many
Many - to - one
Many - to - many
Participation constraints
Total
Partial
Weak entity set

ER Diagram
ERD is a tool for designing databases
Peter P. Chen proposed the ER model in 1976
Conceptual data model

views the real world as a set of entities and


relationships/associations between these entities.

ERD Components
Primary Components of ERD
Entity
Attribute
Relationship

ERD Components Contd.


Entity
Distinguishable object (person, place, thing, event or object) about
which information is stored.

Example:- employee, department.


Entity Set:-

employee
department

Set of entities of same type that share same properties/attributes.

Classification

Physical
Abstract
Independent
Dependent

ERD Components Contd.

Attributes
Properties of entity . Each attribute has a domain.

Example:- employee(emp. no., name, dept, desig, DOB, age)


l_name

f_name
emp_no

desig.
name

dept

employee
DOB
Phone no

Domain eg.
Age={22,23,---,55}
name= character
string of length 15

Attributes Contd.
Classification

Key and Non-key attributes


key:- emp. no
non-key: - name, dept, desig
Simple and Composite
simple:- emp. no
composite:- name
Required and Optional
required:- emp. no optional:- spouse
Stored and derived
stored:-date of birth derived:-age
Single-valued and multivalued
single valued:- age multivalued:- qualification

ERD Components Contd.


Relationship
Association among two or more entities

Degree of a relationship
No. of entities associated with the relationship
Degree 2: binary (common and widely used)
Degree 3: ternary
Degree n: n-ary

Notation:Binary
E1

Ternary
R

E2

E1

R
E3

E2

Example showing a binary relationship


Phone

Address

DOB
Name

Employee

Wor
ks_f
or

Dept_
id

Name

Department
location

Emp_id

Entities:1. Employee 2. Department


Relationship:1. works _for

Cardinality Constraints
Cardinality

Actual no. of related occurrences for each of the two entities.


Types

1-to-1

1-to-Many

Many-to-1

Many-to-Many

Cardinality Examples(1:1 & N:1)

Book_i
d

Stud
_id

Title
Book

Iss
ue

Student

Name
Dept

Author
Name

Address
Name
Professor
Phone

Belo
ng
to

Department

Locati
on

Cardinality Examples(1:N & N:M)

Stud
_id

Phone

Name
Professor

gui
de

Name

Student

Dept

Address
Name

Department

Course
_id

Name
Student
Stud_id

enroll

Course

Credit

Participation Constraint
An entity set may participate in a relation either totally or partially.

Total Participation:- Every entity of an entity type is related to some


other entity set via a relationship type.

Partial Participation:- If only few members of an entity type is related


to some other entity set via a relationship type.

E1

E2

R
Total

Partial

Total/partial participation examples

Stud
_id

Phone

Name
Professor

gui
de

Student

Name
Dept

Address
Name

Address
Name
Professor
Phone

enroll

Department

Locati
on

Weak entity
Weak entity:

can be identified uniquely only by considering the primary key of


another (owner) entity.
Owner entity set and weak entity set must participate in a one-tomany relationship set.
Weak entity sets must have total participation in this identifying
relationship set.

Owner entity

W
Weak entity

Always Total

Weak entity set example


Professor
sectid

Courseid

Name

Course

credits

Has
Section

room
Section

year

semester

Example
name
emp
_no

dept
Employee
N

DOB
works
_for

location
1

work
s_on

Department
M

P_no.

Project

P_name
.

budget

dep_no.

dep_na
me