0% found this document useful (0 votes)
8 views

Db-Lecture 9

database

Uploaded by

saimayousaf.csit
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Db-Lecture 9

database

Uploaded by

saimayousaf.csit
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 27

Database

Management
Systems

Lecture -9
Overview of Lecture

Relationships in E-R Data


Model
Types of Relationships
Relationships
• A relationship is any association, linkage, or connection
between the entities. it is a two directional, significant
association between two entities instances.
• Entities enrolled in a relationship are called its participants.
Examples
• A BOOK STORE orders BOOKs
• MANAGER manages DEPARTMENT
• AUTHOR Writes BOOK

.
:Example of Relationship

DEPARTME
MANAGER manages NT
Degree of Relationship

• The degree of a relationship is the


number of entity types that
participate(associate) in a
relationship.
Types of Relationships:

• Unary Relationship
• Binary Relationship
• Ternary Relationship
Unary (degree 1)
• A unary relationship exists when
both the participating entity type
are the same. When such a
relationship is present we say that
the degree of relationship is 1.
• There are 3 main types of relationship in
a database:
• one-to-one
• one-to-many
• many-to-many
One –to-many
Binary Relationship
• A binary relationship exists when exactly two
entity type participates. Its means that a type
of relationship that involves two entity types is
called binary relationship. This type of
relationship has degree two. The real life used
relationship type.
• There are 3 main types of relationship in a
database:
• one-to-one
• one-to-many
• many-to-many
• One to One Relationship: This type of
relationship is rarely seen in real world.
• The above example describes that one
student can enroll only for one course and a
course will also have only one Student. This
is not what you will usually see in
relationship.
• One to Many : It reflects business rule
that one entity is associated with many
number of same entity. The example for
this relation might sound a little weird,
but this means that one student can enroll
to many courses, but one course will have
one Student.

• The arrows in the diagram describes that


one student can enroll for only one course.
• Many to One : It reflects business rule
that many entities can be associated with
just one entity. For example, Student
enrolls for only one Course but a Course
can have many Students

Many to Many :
• The above diagram represents that many
students can enroll for more than one
courses.
Learn by example

DID

DNam
e

Works
Departmen
In t

Above drawn ER-D is describing 1-1 Repaltionship


Which means that 1 Employee work in Department.
And Department can have 1 employee.
Learn by example
DI
D
DNam
e

Works
Departmen
In t

bove drawn ER-D is describing that Many Employees work in Department.


nd Department can have many employees.
Learn by example
DID

DNam
e

Works
Departmen
In t

Above drawn ER-D is describing M:N Relationship


Which mean that 1 employee can work in many departments
and 1 department can have many employees.
Ternary Relationship

A Ternary relationship is the one


that involves three entities
Example - E/R Diagram
Price

Description Product

Has A

Name Supplier City

Phone number Postcode Street address


Entity
Relationship
Modelling
Cardinality of
Relationship
• Cardinality is defined as how many number
of Entity type instances can participate in a
relation ship with another entity type
instances.
• In another words say we have Entity named
X and Y , so how many instances of X can
make Relation with the instances of Y entity.
• Cardinality limit the number of instances
which can make relationship.
Types of Relationship
Cardinalities
• The maximum number of
instances of one entity that may
associated with each instance of another
entity is known as maximum
cardinality.
• The minimum number of instances of
one entity that may associated with each
instance of another entity is known
as minimum cardinality.
Types of Cardinalities
Notations for Cardinality
Description of Cardinalities
Examples of Different
Cardinalities
Supertype and Subtypes
• An entity be divided into several subtype. An
entity type that can be subdivided into
subtype is called super type. A sub type is a
subset of a supertype that share common
attributes. Subtypes behave in exactly the
same way as any entity type .
Super/
Subtypes Id

Address Name

PERSON

StId Qual

STD FAC

CGPA ClsName Grade


Super/
Subtypes
General Entity Types

ST PERSON

ST1 ST2 ST3 STD FAC

Specialized Entity Types

You might also like