Download presentation
Presentation is loading. Please wait.
1
Database Systems Instructor Name: Lecture-9
2
Contents Degree of Relationship Cardinality of Binary Relationship 2
3
Degree of Relationship
Number of Participating Entity Types in a Relationship Types of Degrees of Relationship Unary Binary Ternary 3
4
Unary Relationship It is the relationship between Entity Instance of the same Entity Type, also called Recursive Relationship Usual Situations When Unary Relationship exist are: One to One Relationship, when an entity instance is associated with exactly one entity instance, for example, married to in PERSON entity type One to Many Relationship, when an entity instance is associated with more than one entity instance 4
5
Unary Relationship-Contd.
To Establish a Sequence, Cycle or Priority List between entity instances Employee Manages Employees Courses are pre-requisite to other courses Categories with lower level of categories 5
6
Unary Relationship-Example
6
7
Binary Relationship Relationship between two Entity Types
It is the most common type of relationship encountered in ER Diagram 7
8
Binary Relationship- Example
8
9
Ternary Relationship It is a simultaneous relationship among instances of THREE entity types 9
10
Ternary Relationship- Example
10
11
Ternary Relationship Caution:
A Ternary relationship is not three binary relationship as the relationship supply with attribute cannot be associated with any of the given Entity Type With associative Entity Type the Ternary Relationship becomes: 11
12
Ternary Relationship- Example
12
13
Ternary Relationship – How to Resolve?
Convert all ternary relationship to associative entities 13
14
Notations for Relationship
Weak Relationship also called defining relationship 14
15
Relationship Constraints
Limits the possible combination of entities that participate in the corresponding relationship set For Example, if company rule dictates that an employ can work for only one Manager, this is a constraint on relationship One student can be enrolled in many courses One student majors in one department WHY, relationship constraints? Better Manipulation of Data Enforce Constraints If not represented in conceptual model, the domain knowledge may be lost 15
16
Types of Cardinality on Binary Relationship
One to one One to many ( or many to one) Many to many 16
17
Notations for Cardinality on Binary Relationship – Crow’s Foot Notation
17
18
One-to-One Relationship
A single Entity Instance from Entity Type is associated with a single Entity Instance of another Entity Type 18
19
One-to-One Relationship - Example
19
20
One-to-Many Relationship
A single Entity Instance in one Entity Type is associated with a multiple Entity Instances of another Entity Type Also, called Parent – Child Relationship OR Master– Detail Relationship (Oracle) 20
21
One-to-Many Relationship - Example
21
22
Many-to-Many Relationship
Each Entity Instance in one Entity Type is associated with a multiple Entity Instances of another Entity Type; and vice versa. 22
23
Many-to-Many Relationship - Example
23
24
Cardinality Constraint on Binary Relationship
Cardinality Constraint specifies: Number of Instances of One Entity Type that must be associated with each Instances of another Entity Type OR Maximum Number of Relationship Instances that an Entity can participate in. ATTRIBUTE ON RELATIONSHIPS Attribute on one-to-one relationship can be moved to either side of Entity Type Attribute on one-to-many relationship can only be moved to “many” side of the relationship 24
25
Cardinality Constraints – Contd.
Cardinality means “count” and expressed as number Minimum Cardinality: The minimum number of instances of one Entity that may participate in a relationship with each Instance of another Entity Maximum Cardinality: The maximum number of instances of one Entity that may participate in a relationship with each Instance of another Entity 25
26
Cardinality means “count” and expressed as number
Minimum Cardinality Cardinality means “count” and expressed as number Minimum Cardinality: The minimum number of instances of one Entity that may participate in a relationship with each Instance of another Entity 26
27
Minimum Cardinality – Contd.
Minimum is generally stated as either ‘Zero’ or ‘One’ Zero (optional participation): participation in relationship by the entity is option One (Mandatory participation): Participation in relationship by the entity is mandatory 27
28
Minimum Cardinality – Example
28
29
Cardinality with Optional and Mandatory Participation – Example
29
30
Participation Constraint
It defines whether the existence of an entity depends on its being related to another entity via relationship type. This is also alternative way to define minimum cardinality constraint and its implications (optional, mandatory) 30
31
Participation Constraint Types
Total Participation Partial Participation 31
32
Case I – Total Participation
If company policy states that Every Employee Must work for a department, Then Employee Entity Only Exist if it participate in at least ONE work-for relationship It is total participation as Every Entity Instance in the EMPLOYEE entity type must be related to a department via work-for relationship Total Participation is also called Existence Dependency 32
33
Case II – Partial Participation
We do not expect every employee to manage a department, so the participation of employee in manage relationship is Partial Some or part of employees from employee set are related to some departments; and not all employees. 33
34
Maximum Cardinality Maximum Number of One Entity that may be associated with each instance of another Entity Crow’s Foot 34
35
Crow’s Foot - Notations
35
36
Relationships and Cardinalities – Mandatory Cardinality - Example
36
37
Relationships and Cardinalities –Optional Cardinality - Example
37
38
Cardinality Constraints on Ternary Relationship
38
39
???????????????? 39
40
Assignment – What I was Expecting
major Department offers Is double major allowed? Can a student have more than 1 advisor? Is joint appointment of faculty possible? Can two profs share to teach the same course? Can a professor teach more than one course? Can a professor stay without affiliated with a department? faculty Courses teaches Professor advisor enrollment Students 40
41
Erroneous Relationship
Receives or summarize the data, transfer, translate or calculate data 41
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.