You are on page 1of 39

ENTITY RELATIONSHIP

DIAGRAM

BY
MEER SADAF NAEEM
Part-1

Understanding the
Fundamentals
BASIC CONCEPTS
WHAT IS ENTITY?
 Person
WHAT IS ENTITY?
 Place
WHAT IS ENTITY?
 Object
WHAT IS ENTITY?
 Event
ATTRIBUTES

Descriptive properties possessed


by each member of an entity set.

Student

Name Address Class Roll number Percentage


ENTITY SET/TYPE:

Set of entities of the same type


that share the same attributes.

ENTITY SET : STUDENT

Student A Student B Student C Student D


ENTITY SET : STUDENT

STUDENT A STUDENT B STUDENT C STUDENT D

ENTITY SET : TEACHER

Mr. A Mr. B Mr. C Mr.D


What is relationship?

Meaningful association
among several entities.
RELATIONSHIP SET/TYPE:

A set of relationships of the


same type.
RELATIONSHIP SET : SUBJECT
ENTITY SET : STUDENT ENTITY SET : TEACHER

Student A Mr. A

Student B Mr. B

Student C Mr. C
DEGREE OF RELATIONSHIP SET

The number of entity sets that


participate in a relationship
set.
RELATIONSHIP SET : SUBJECT

ENTITY SET : STUDENT ENTITY SET : TEACHER

Student A Mr. A

Student B Mr. B

Student C Mr. C
TYPES OF ATTRIBUTES
 Single and composite:
1. roll number is an example of single
attribute as it can not be divided
further.
2. Name can be divided further into 3
parts consisting of first name , middle
name , last name so it is an example of
composite attribute.
TYPES OF ATTRIBUTES
 Single valued and multivalued:
1.The attributes which have single
value are single valued attributes
such roll number.
2.The attributes which has a set of
values are called multivalued
attributes. Such as any student can
have more than 1 telephone
number .
TYPES OF ATTRIBUTES
 Derived attribute:
• These attributes are derived from
the existing attributes of entities.

• The value of a derived attribute is


not stored , but computed when
required.
Student

Name Address Class Roll number Date-of-birth


TYPES OF ATTRIBUTES
 Descriptive attribute:

• The attribute of the relationship is


called descriptive attribute.
Cardinality

It expresses the number of entities to which


another entity can be associated via a
relationship set.

 One to many
 Many to one

 One to one

 Many to many
ONE TO MANY
A B
a1 b1

a2 b2

a3 b3

a4 b4
MANY TO ONE

A B
a1

b1
a2

a3
b2
b2

a4

b3
a5
ONE TO ONE

A B

a1 b1

a2 b2

a3 b3

a4 b4
MANY TO MANY

A B
a1 b1

a2 b2

a3
b3

a4 b4
ROLE

The function that an entity plays in a


relationship is called that entity’s role.

 Not specified when entity sets that


participate in a relationship set are
distinct.
 Clarification is needed only when the
entity sets of a relationship set are not
distinct.
RECURSIVE RELATIONSHIP

When entities are self-linked then


such a relationship is called a
recursive relationship.
TOTAL PARTICIPATION

The participation of an entity set E in a


relationship set R is said to be TOTAL if
every entity in E participates in at least one
relationship in R.
RELATIONSHIP SET : SUBJECT

ENTITY SET : STUDENT ENTITY SET : TEACHER

Student A Mr. A

Student B Mr. B

Student C Mr. C
PARTIAL PARTICIPATION

The participation an entity set E in a


relationship set R is said to be PARTIAL if
only some entities in E participate in
relationships in R.
RELATIONSHIP SET:COURSE
FACULTY COURSES

MR.A DBMS

MR.B
JAVA

MR.C

CALCULUS
MR.D
Design issues
 Example : should location be an entity
or attribute?
 Can a project be in more than one
location?
 Does location need to be described in
more detail?
Weak entity set

An entity set that does not have sufficient attributes to


form a primary key is referred to as a weak entity set.
 Existence of weak entity set depends on the
existence of a strong entity set which is
called the identifying entity set.
 The relationship is always many-to-one from
weak to identifying.
 Participation of the weak entity set in the
relationship must be total.
Part-2

Introducing to Identifiers
Identifiers
 Candidate Key
• All available unique, required identifiers of an entity
 Primary Key
• A unique, required identifier of an entity
• The best one of candidate keys
 Foreign Key
• A reference key to another entity
• This key is the primary key of another entity
Primary Key
 Natural primary key:
A natural primary key is one that exists in
the data itself.
 Surrogate primary key:

The primary key that you have created


where non existed before.
 Primary key requires the consideration
not just of the current data, but of
possible future data as well.
Why is it important to identify
primary key?
 The primary key is the main “Handle” that
the database server uses to grab the
information in which you are interested.

 By identifying a primary key, you are telling


the server which information you want to
work with at the moment.
Foreign Key
 A primary key of one table that is
included in another table.

 Links the records in one database table


to another table.

You might also like