Cardinality of a Relationship
1.Cardinality defines the number of entities in one entity set,
which can be associated with the number of entities of other
set via relationship set.
2.Relationship cardinalities specify how many of each entity
type is allowed.
3.Relationships can have four possible connectivities as given
below.
Dr.Businge Phelix Mbabazi 3
Con’t
1.One to One (1:1) Relationship
2.One to Many (1:N) Relationship
3.Many to One (M:1) Relationship
4.Many to Many (M:N) Relationship
The minimum and maximum values of this connectivity is called
the Cardinality of the Relationship
Dr.Businge Phelix Mbabazi 4
Con’t
1.One-to-One Relationship
In One-to-One Relationship, One entity from entity set A can be
associated with at most one entity of entity set B and vice versa.
Example: Employee is assigned with a parking space.
5 Dr.Businge Phelix Mbabazi
Con’t
1.One employee is assigned with only one parking space and
one parking space is assigned to only one employee.
2.Hence it is a 1:1 Relationship and Cardinality is One-To-One
(1:1)
3.In ER modeling, this can be mentioned using notations as
given below
Dr.Businge Phelix Mbabazi 6
Con’t
2.One-to-Many Relationship
In One-to-Many Relationship, One entity from entity set A can be
associated with more than one entities of entity set B however
an entity from entity set B, can be associated with at most one
entity.
•For example, Organization has employees
7 Dr.Businge Phelix Mbabazi
Con’t
1.One organization can have many employees, but one
employee works in only one organization. Another
example of a 1:N relationships is a department has many
employees and each employee is assigned to one
department.
2.Hence it is a 1:N relationship and cardinality is One-To-
Many (1:N)
3.In ER modeling, this can be mentioned using notations as
given below
Dr.Businge Phelix Mbabazi 8
Con’t
2.Many-to-One Relationship
1.In Many-to-One Relationship, More than one entities from
entity set A can be associated with at most one entity of
entity set B, however an entity from entity set B can be
associated with more than one entity from entity set A.
2.Example: Employee works in organization
Dr.Businge Phelix Mbabazi 9
Con’t
Dr.Businge Phelix Mbabazi 10
•One employee works in only one organization But one
organization can have many employees.
•Hence it is a M:1 relationship and cardinality is Many-to-One
(M :1)
Con’t
•In ER modeling, this can be mentioned using notations as
given below.
Dr.Businge Phelix Mbabazi 11
Con’t
4.Many-to-Many Relationship
1.In Many-to-Many Relationship, One entity from A can be
associated with more than one entity from B and vice versa.
2.Example: Students enrolls for courses
Dr.Businge Phelix Mbabazi 12
Con’t
•One student can enroll for many courses and one course can
be enrolled by many students.
•Hence it is a M:N relationship and cardinality is Many-to-Many
(M:N)
•In ER modeling, this can be mentioned using notations as
given below
Dr.Businge Phelix Mbabazi 13
Dr.Businge Phelix Mbabazi 14
Dr.Businge Phelix Mbabazi 15
Dr.Businge Phelix Mbabazi 16
Advantages of ER Modeling
1.Conceptually it is very simple: ER model is very simple because if we know
relationship between entities and attributes, then we can easily draw an ER
diagram.
2.Better visual representation: ER model is a diagrammatic representation of any
logical structure of database. By seeing ER diagram, we can easily understand
relationship among entities and relationship.
3.
Effective communication tool: It is an effective communication tool for database
designer.
4.
Highly integrated with relational model: ER model can be easily converted into
relational model by simply converting ER model into tables.
5.
Easy conversion to any data model: ER model can be easily converted into
another data model like hierarchical data model, network data model and so on
Dr.Businge Phelix Mbabazi 17
Disadvantages of ER Modeling
1.Limited constraints and specification
2.Loss of information content: Some information be lost
or hidden in ER model
3.Limited relationship representation: ER model
represents limited relationship as compared to another
data models like relational model etc.
4.No representation of data manipulation: It is difficult
to show data manipulation in ER model.
5.Popular for high level design: ER model is very popular
for designing high level design
Dr.Businge Phelix Mbabazi 18
The Enhanced ER Model
As the complexity of data increased in the late 1980s, it
became more and more difficult to use the traditional
ER Model for database modelling. Hence some
improvements or enhancements were made to the
existing ER Model to make it able to handle the complex
applications better.
Hence, as part of the Enhanced ER Model, along with
other improvements, three new concepts were added to
the existing ER Model, they were:
1.Generalization
2.Specialization
3.Aggregation
Dr.Businge Phelix Mbabazi 19
SUPER TYPES AND SUBTYPES
1.Super type - an entity type that relates
to one or more subtypes.
2.Subtype - a subgroup of entities with
unique attributes.
3.Inheritance - the concept that subtype
entities inherit the values of all super
type attributes.
Dr.Businge Phelix Mbabazi 20
Generalization
Generalization is a bottom-up approach in which two
lower level entities combine to form a higher level entity.
In generalization, the higher level entity can also
combine with other lower level entities to make further
higher level entity.
It's more like Superclass and Subclass system, but the
only difference is the approach, which is bottom-up.
Hence, entities are combined to form a more generalized
entity, in other words, sub-classes are combined to form
a super-class.
Dr.Businge Phelix Mbabazi 21
For example, Saving and Current account types entities can be
generalized and an entity with name Account can be created,
which covers both.
Dr.Businge Phelix Mbabazi 22
Specialization
Dr.Businge Phelix Mbabazi 23
Specialization
Specialization is opposite to Generalization. It is a
top-down approach in which one higher level entity
can be broken down into two lower level entity. In
specialization, a higher level entity may not have any
lower-level entity sets, it's possible.
Dr.Businge Phelix Mbabazi 24
Aggregation
Aggregation is a process when relation between two
entities is treated as a single entity.
In the diagram below, the relationship between
Center and Course together, is acting as an Entity,
which is in relationship with another entity Visitor.
Now in real world, if a Visitor or a Student visits a
Coaching Center, he/she will never enquire about the
center only or just about the course, rather he/she will
ask enquire about both.
Dr.Businge Phelix Mbabazi 25
Aggregation
Dr.Businge Phelix Mbabazi 26
Class Exercise1
Using an organization of your choice, identify the
database of your choice by identifying at least four
entities plus at least four attributes .
Use modeling software like Microsoft visual ,argoUML,
Lucidchart, BOUML, Edraw Max, Stella e.t.c draw
1.Conceptual data model
2.Logical data model
3.Physical data model
4.Class Diagram
Dr.Businge Phelix Mbabazi 27