Sunteți pe pagina 1din 24

09/11/2020 Badakhshan University Faculty of Computer 1

Science
Islamic Republic of Afghanistan
Ministry of Higher Education
Badakhshan University
Computer Science Faculty

Database Fundamentals

09/11/2020 Badakhshan University Faculty of Computer 2


Science
Lecture #6

Entity Relationship (E-R) Model) (Continue)

09/11/2020 Badakhshan University Faculty of Computer 3


Science
Elements of ER Model…….

Entity relationship ( E-R ) Model involve different types of elements such us:
1 . Entity
2. Attribute
3. Relationship

09/11/2020 Badakhshan University Faculty of Computer 4


Science
3. Relationship :
A relationship is an association representing an interaction among the
instance of one or more entity types that is interest to the organization
The relationship may be between different entities or between an entity
itself.
A relationship is established on the basis of interaction among these
entities.
For example : a relationship exist between employ and department
because the employ works on department

09/11/2020 Badakhshan University Faculty of Computer 5


Science
Attribute on Relationship
Some times there are some attributes that is represented in the time of
relationship.
These attributes have its own meaning in ER diagram.
That attribute which are represented in the time of relationship are not
associated or related to another entity, because these attributes are the
properties of relationship
For example : we have two entity TEACHER and COURSE

09/11/2020 Badakhshan University Faculty of Computer 6


Science
Example Attributes of Relationship

COMPLETE

09/11/2020 Badakhshan University Faculty of Computer 7


Science
Associative Entity :
Associative entity is a type of entity that associates the instance of one or
more entity types
Associative entity contain the attributes that are related to the
relationship, these attributes are not related to another entity which are
presented in the relationship
Associative entities are represented as rectangle with rounded corners.
In ER diagram the associative entity has independent meaning to end
user

09/11/2020 Badakhshan University Faculty of Computer 8


Science
Degree of Relationship :
Each relationship consist of many entities.
The degree of relationship is the number of entity types that participate
in the relationship is called degree of relationship.
There are three most common relationship degree in E-R model
1. Unary Relationship
2. Binary Relationship
3.Ternary Relationship

09/11/2020 Badakhshan University Faculty of Computer 9


Science
1.Unary Relationship :
Unary Relationship is a type of relationship that is established between
the instance of a single entity type or it is established between the instance
of same entity type.

PERSON

manage Teach
Lives
with

09/11/2020 Badakhshan University Faculty of Computer 10


Science
2. Binary Relationship :
Binary Relationship is a type of relationship that is established between
the instance of two entity type
It is the most common type of relationship in data modeling
There are different types of binary relationship
1. One –to- one Relationship
2. One-to-many Relationship
3. Many-to-many Relationship

09/11/2020 Badakhshan University Faculty of Computer 11


Science
1.One-to-one Relationship :
This is a type of relationship is used when, for each instance in first entity
type there is only one instance in the second entity type.
And for each instance in the second entity type, there is only one instance
in the first entity type .
1 1
MANAGER
manage BRANCH

The above relationship means that one manager manage one branch.
Similarly, one branch is manage by one manager.

09/11/2020 Badakhshan University Faculty of Computer 12


Science
Example of One to One Relationship

09/11/2020 Badakhshan University Faculty of Computer 13


Science
Example of One-to-One Relationship :
Has
1 1
COUNTRY Has PRESIDENT

The above relationship means that one country has one president.
Similarly, one president of only one country
1 1
CHAIRMAN Run UNIVERSITY

The above relationship means that one chairman run only one university.
Similarly, one university is run by one chairman

09/11/2020 Badakhshan University Faculty of Computer 14


Science
Example of One-to-One Relationship : MAYOR
1 1
MANAGER Manage BRANCH

Has GOVERNER
PROVINCE
1 1

1 1
CITY Has MAYOR

09/11/2020 Badakhshan University Faculty of Computer 15


Science
2. One-to-Many Relationship :
This is a type of relationship is used when, for each instance in first entity
type there can be many instance in the second entity type.
And for each instance in the second entity type there is only one instance
in the first entity type. 1 M
Has

The above relationship means that one province can have many district,
but one district is only belong to one province.

09/11/2020 Badakhshan University Faculty of Computer 16


Science
One-to-Many Example

09/11/2020 Badakhshan University Faculty of Computer 17


Science
Many-to-One Example

09/11/2020 Badakhshan University Faculty of Computer 18


Science
Example of One-to-Many Relationship
1 M
Has

the above relation means that one faculty can have many departments,
but one department is only belong to one faculty.
1 M
Work
the above relationship means that in one department can work many
employ, but one employ can only work on one department

09/11/2020 Badakhshan University Faculty of Computer 19


Science
Example of One-to-Many Relationship

COUNTRY Has PROVINCE

Faculty Has DEPARTMENT

HASBAND Has WIFE

09/11/2020 Badakhshan University Faculty of Computer 20


Science
3. Many-to-Many Relationship :
Many-to-Many Relationship is a type of relationship used when, for each
instance in first entity type, there can be many instance in the second
entity type
And for each instance in second entity type, there can be many instance
in the first entity type

Study

The above relationship means, that one student may study more course,
and one course may be studied by more students

09/11/2020 Badakhshan University Faculty of Computer 21


Science
Many-to-Many Example

09/11/2020 Badakhshan University Faculty of Computer 22


Science
2. Many-to-Many Relationship :

Has
The above relationship means that one employ learn many skills and one
skill can be learned by many employees.

Read

The above relationship means that one reader may read many books and
one book may be read by one reader

09/11/2020 Badakhshan University Faculty of Computer 23


Science
Any Questions & Suggestions

Email: mqm.dacaar@gmail.com
Phone: +0789152242

09/11/2020 Badakhshan University Faculty of Computer 24


Science

S-ar putea să vă placă și