2 Chapter 2
2 Chapter 2
Presented by
Dr. Md. Abir Hossain
Dept. of ICT
MBSTU
Reference Book: INTRODUCTION TO DATABASE MANAGEMENT SYSTEM
by Dr. Satinder Bal Gupta & Aditya Mittal
INDEX
i. Introduction
ii. Basic Concepts
iii. Types of Attribute
iv. Relationship Sets
v. Mapping Constrains
vi. Keys
vii. Entity – Relationship Diagram
viii. Types of Entity Sets
ix. Enhanced Entity-Relationship (EER) Model
x. Reduction of an E-R and EER Diagram into tables
Introduction
➢ Entity-Relationship model, is a high-level data model used in Database Management
Systems to represent the logical structure of database.
➢ It is conceptual design that simplifies the of data by defining entities, attributes, and
relationships between them.
Basic Concepts
▪ Enterprise: Enterprise refers to any kind of organization.
Ex. School, Colleges any company etc.
▪ Entity: Entity refers to an “object” or “thing” in real world. Object may be any person, place, event etc.
Ex. Students of colleges and schools, loans in banks, employees in any company etc.
▪ Value: Value is the information or data which is stored in attributes of any entity.
▪ Entity Sets: All the entities having same attributes make an entity set.
▪ Domain: Domain or value set is the set of all values or information about any attribute.
Ex. Consider the student table shown in Figure 2.1. It describes the basic concepts.
Types of Attributes
1. Simple and Composite Attribute
i) Simple: Attributes are those which cannot be divided into subparts.
Ex. Age of a student.
ii) Composite: Attributes are those which can be divided into subparts.
Ex. Name of a student can be divided into First Name, Middle Name, and Last Name.
*NULL Value : Null stands for nothing. An attribute have a null value if either the value of that attribute
is not known or the value is not applicable.
Caution: NULL is not equal to Zero (0). But you can say that NULL is blank as shown in Figure 2.2.
Relationship Sets
a) Relationship: A relationship is the association among several entities. It connects different
entities through a meaningful relation.
b) Relationship Set: A relationship set is a set of relationships of the same type.
➢ Ex. Employees work in different departments. Then relationship exists between employees and
departments because each employee must belongs to some department.
➢ Here, Employee and Department are two entity sets. r stands for relationship between Employee
and Department. Works_in is the relationship set as shown in Figure
• Descriptive Attributes : Attributes of any relationship set are known as descriptive attributes. Works_in
is a descriptive attribute.
Degree of Relationship Sets
Total number of entity sets participate in a relationship set is known as degree of that relationship set.
i) Binary Relationship Set: A relationship set in which only two entity sets are involved is
known as binary relationship set.
Ex.
ii) Ternary Relationship Set: A relationship set in which three entity sets are involved is known as
ternary relationship set or a relationship set having degree three.
Ex.
Role and Recursive Relationship Set
Total number of entity sets participate in a relationship set is known as degree of that relationship set.
▪ Role : The function of any entity which it plays in relationship set is called that entity’s role.
Ex. Employee plays the role of worker in his department in Figure 2.4.
▪ Recursive Relationship Set : When the same entity sets participate in same relationship set more
than once with different roles each time, then this type of recursive relationship set is known as
Recursive Relationship set.
For example, consider a relationship set works_in and two entity set student and college. A
student who attends weekend classes in college as student may also be lecturer in that college.
Then this person plays two roles (student, faculty) in same relationship set work_in.
Mapping Constrains
(5.a) Mapping Cardinalities (Cardinality Ratios):
It specifies the number of entities of an entity set that are associated with entities of another
entity set through a relationship set.
❑ Types of Mapping Cardinalities:
1. One to One (1 : 1) : An entity in X is associated with at most one entity in Y and an entity in Y
is associated with at most one entity in X.
Ex. A country has only one president. Any person may be the president of at most one
country
Figure: N :1 relationship
4. Many to Many (M : N) : An entity in X is associated with any number (zero or more) of entities in Y and
vice versa.
Ex. A student can have more than one subject and one subject can be given to more than one student.
Figure: M: N relationship
Participation Constraints :
It tells the participation of entity set in relationship sets.
❑ There are two types of participations:
1. Partial participation : If only some entities from entity set E is participated in
relationships in set R then it is known as Partial participation.
Ex. Every customer may or may not take the loan , so Customer entity set is partially participated.
2. Total participation : If every entity from entity set E is participated with at least one
relation in relationship set R then it is known as Total participation.
Ex. Every loan is concerned with at least one customer of bank. So, loan entity set is totally
participated.
Keys
➢ A key is an attribute or set of attributes that is used to uniquely identify data in entity sets.
➢ The attributes which are used as key are known as key attributes. Rest of all are known as Non-key
attributes.
❑ Types of Keys:
1. Super Key : A super key is a set of collection of one or more than one attributes that can
identify data uniquely. Any entity set has more than one super key.
Ex.
6. Foreign Key : A foreign key is an attribute in any entity set which is also a Primary Key in any other
entity set.
Ex. Dept-ID: This is an attribute in entity set Employee(a) and also a primary key in entity set Department(b).
Thus, it is a foreign key in Employee.
Entity Relationship Diagram(E-R Diagram) :
E-R diagrams represents the logical structure of a database. Symbols used in E-R diagrams are shown in Table 2.1.
Ex-1. An E-R diagram having two entity sets, Customer and Item.
Advantages:
1. Straightforward relation representation: The relation representation of the database
model using E-R diagram are relatively more straightforward than other models.
2. Mapping with relational model: It can be easily mapped onto the relational model. The E-R
diagrams used in the E-R model can easily be transformed into relational tables. The entities and
attributes of E-R model can easily be transformed into relations (tables) and columns (fields) in a
relational model.
3. Communication tool: It is very simple and easy to understand with a minimum of training
efforts required. Therefore, the model can be used by the database designer to communicate the
design to the end user.
4. Design tool: E-R model can also be used as a design plan by the database developer to
implement a data model in specific database management software.
5. Easy conversion to other models: E-R diagrams can be easily converted to a network or
hierarchical data model.
6. Graphical representation: E-R model provides graphical and diagrammatical representation
of various entities, their attributes and relationships between entities.
7. Easy to modify: Modifications to E-R diagram at later stage is relatively easier than
in other models.
Limitation:
E-R model cannot express relationships between relationships. In other words, E-R model is not
capable to express relationship set between relationship sets.
This limitation can be overcome by using EER model.
Types of Entity Sets
There are two types of entity sets as given below:
a) Strong Entity Sets: Entity set having any key attributes are known as Strong Entity sets.
Ex. The Figure shows strong entity set Student having key attribute Reg_No.
b) Weak Entity Sets: Entity sets having no key attributes are known as Weak Entity sets.
Ex. The Figure below shows weak entity set Table having no key attributes to identify the tuples
uniquely.
N.B. A weak entity set is always associated with another entity set to make it meaningful.
This another entity set is known as Identifying entity set.
9. Enhanced Entity-Relationship (EER) Model
What is EER?
EER model is basically the enhanced version of E-R model which includes all the basic concepts of
E-R model with capability to support additional semantic concepts of complex applications.
❑ Concepts of EER
▪ Specialization
▪ Generalization
▪ Categorization
➢ Before discussing the concepts of specialization, generalization, and categorization two another
entity types superclass (supertype) and subclass (subtype) are need to be described.
1. Superclass Entity Type (Supertype) : A superclass entity type is a generic entity type that includes
one or more distinct subclasses that require to be represented in a data model.
2. Subclass Entity Type (Subtype) : A subclass entity type is a more specialized entity type that has a
distinct role in the organization. (A subclass is a member of superclass.)
Ex.
9.a) Specialization : Specialization is a process by which any existing entity set is divided into
smaller entity sets according to the distinct or different nature of entities.
9.b)Generalization: Generalization is a process by which two or more entity sets can be
combined into a single entity set by determining similarities between the entities.
Ex.
Here Employee and Customer are two entity sets. They have common feature that both are Person.
❑ Specialization and Generalization Constraints
The following constraints are applied on specialization and generalization to capture important
business rules of the relationships in an enterprise.
Here entity sets Employee and Customer inherits attributes Person_ID, Name, Address, Age from Person entity set.
9.d) Aggregation: Aggregation in DBMS is process of combining two or more entities to form a
more meaningful entity.
Ex.
In this example, the Employee and Branch alone do not make sense and are not useful. However,
when they are combined through the aggregation process, a more meaningful entity Manger is
formed. This New entity can perform better and provide more meaningful information.
9.e) Categorization: The subclass having more than one superclass is known as category and the
process of defining a category is known as Categorization.
Ex.
Categorization Symbol
In a bank, a person can be either an employee or a client and both of them may be investor. So, here Subclass
employee and client act as disjoint Superclasses and subclass investor acts as category.
10. Reduction of an E-R and EER Diagram into tables
To represent the database in tabular form, E-R diagrams have to be reduced in tables. For each
entity set, make different table and for each relationship set make a different table.
Ex.
Consider Figure 2.20 in which Phone-No. is multi-valued attribute. So, make a table with two
columns, one is Emp-ID (primary key of Employee) and second is Phone-No. (multi-valued
attribute). Give any name to that table. The table is shown in Figure 2.22.
If any employee has two phone numbers, then it is possible to make two different entries in table and so on.
Ex.
Consider the E-R diagram shown in Figure 2.24, in which Payment is a Weak entity set that
depends upon Strong entity set Loan(has primary key). So, make a table with table name
Payment having four columns as shown in Figure 2.25.
10.5 Reduction of Relationship Sets
Let R be the relationship set and E1, E2, ..., EN be the entity sets participating in R. Make a table with
table name same as of Relationship Set having columns equal to number of attributes in relationship
set (descriptive attributes) and primary keys of all participating entity sets.
Ex.
Consider the ER diagram shown in Figure 2.20, having relationship set Works-in having two
participating entity sets, Employee and Department. The corresponding table is shown in Figure
2.26.