E - R Model-4
E - R Model-4
Entity Relationship
(E – R) Model
(BCA-108)
1
S.P. Chauhan
Database Design
• Database Design:-
The systematic process of designing a database is known as Design Methodology or Database Design.
It is the process of designing logical & physical structure of one or more database. The reason behind
it is to accommodate the information needs or queries of the user, a defined set of applications and to
support the overall operations and objective of an enterprise.
Database design involves understanding operational and business needs of an organization, modeling
the specified requirements and understanding the requirements using a database. The goal of database
design are:
a) Database should provide the efficient storage, update and retrieval of data.
b) Database should be reliable and have high integrity to promote user’s trust in database.
c) To produce an efficient, high-quality and minimum cost database.
A good database design and implementation process consists of following phases:
i. Data requirements collection & analysis.
ii. Conceptual database design.
iii. DBMS selection
iv. Logical database design
v. Physical database design
vi. Database system implementation
vii.Testing & evaluation
S.P. Chauhan 2
Database Design
• Database Design:-
i. Data requirements collection & analysis:-
It is the process of knowing and analyzing the expectations of the user for the new database
application in as much detail as possible. It is done by a team of analysts or requirements experts by
reviewing the current file processing system OR existing DBMS system and interact with the user to
analysis the nature of the business area to be supported. It include the following activities:
a) Collection and analysis of current data processing.
b) Studying the current operating environment and planned use of the information.
c) Collection of written responses to set of questions form the database users or user group to know
the user priorities and importance of application.
d) Analysis of general business function and their database need.
e) Justify need of new database in support of business.
ii.Conceptual database design:-
Once the requirements of the user have been specified, the next step is to construct an abstract or
conceptual model of database based on the requirement of user, it is known as conceptual database
design/ modeling or semantic modeling. Conceptual schema is independent of any specific DBMS.
It mainly focus what data are required and how they should be organized rather then what
operations are to be performed. In this phase a high level description of data and constraints are
developed. Generally entity-relationship (E-R) diagram is used to represent conceptual database
design. The conceptual database design include the following activities: S.P. Chauhan 3
Database Design
• Database Design:-
ii.Conceptual database design:-
The conceptual database design include the following activities:
a) Identification of scope of database requirements for proposed system.
b) Analysis of overall data requirements for business function
c) Developing a detailed conceptual data model, including all entities, their attributes ,
relationship among them and constraints or business rule if any.
d) Specifying functional characteristics of database transaction by identifying their inputs/ outputs
& functional behavior.
iii. DBMS selection:-
The selection of DBMS depends mainly on two factors one is cost that include DBMS features &
tools, portability, DBMS hardware requirements, cost of staff training and maintenance cost etc.
Second is technical factors that include storage structure, access path, type of user/ programmers
interface, types of high-level query language and the architecture it supports.
iv. Logical database design:-
After the appropriate DBMS is chosen, the next step is to map the high-level conceptual schema
onto the implementation of data model of the selected DBMS. In this phase, the database designer
moves from an abstract data model to the implementation of the database. E.g. In the case of
relational model this phase generally consists of mapping E-R model into relational model. Logical
database design include the following steps.
S.P. Chauhan 4
Database Design
• Database Design:-
iv. Logical database design:-
Logical database design include the following steps.
a) Creating conceptual schema & external schema into data model of selected DBMS by mapping
those schemas produced in conceptual database design. i.e. Integrating database views into
conceptual data model
b) Organizing the data into non redundant groupings based on the data relationship, nature of
DBMS and the application that will use the data.
c) Detail analysis of transactions, forms and database views(inquiries).
d) Identifying data integrity and security requirements.
v. Physical database design
In physical database design the physical schema (internal schema) is designed in terms of physical
storage structure, record placement, indexes and access path for the database files are also specified
to achieve good performance. It includes the following:
a) Selecting the data storage and data access characteristics of the database.
b) Producing a description of implementation of the database on secondary storage.
c) Deciding physical organization of data.
d) Designing database processing program
S.P. Chauhan 5
Database Design
• Database Design:-
vi.Database System implementation:-
Once the logical and physical database design are completed, the database system can be
implemented. DDL statements of selected DBMS are used and compiled to create database schema &
database files and finally database is loaded with the data.
v.Testing & Evaluation:-
In this phase database is tested for the performance, integrity, concurrent access and security
constraints. This phase is carried out in parallel with application program written in standard
programming language such as java, VB, etc or in special database language such as SQL or special
purpose non procedural language. If testing fails then various actions are taken such as modification
of physical design, logical design or upgrade/ change DBMS software or hardware. It include the
followings:
a) Coding and testing database program.
b) Documentation of complete database & users’ training manual.
c) Installation of database.
d) Error fixing in database and database applications
e) Importing data from the earlier system if any.
S.P. Chauhan 6
Entity - Relationship Model
• Entity – Relationship Model (E – R Model):-
It is most popular conceptual model used for designing a database. It was introduced by Dr. Peter
“Chen” in 1976. it defines what should be stored in database, About what, What data and how it is
related. This data model is based on real world that consists of basic objects called entities, their
attributes and relationship among these objects. i.e. an E – R model may be defined as a conceptual
data model that views the real world as entities, their attributes and relationship among them.
Features of E – R Model:-
i. It is high level conceptual data model.
ii. It allow us to describe the data involved in a real world in terms of objects and their relationship.
iii. It is widely used to develop an initial design of a database.
iv. It provides a set of useful concepts that make it convenient for a developer to move from basic
set of information of what user want from their database to detail description that can be easily
implemented in a database management system.
v. It describe data as a collection of entities, relationship and attributes
Entity:-
An entity is an object or a thing in real world with an independent existence and distinguishable
from other objects i.e. It is an object of concern use which represents the thing in real world. An
entity can be a physical quantity such as car, person etc. or it can be non physical quantity such as
project, loan etc it represent the class of things not instance.
S.P. Chauhan 7
Entity - Relationship Model
Entity:-
i.e. an entity is distinguishable object that has an independent existence in the real world and
organization is interested to store information about it.
Tangible OR Concrete Entity:-
Those entities which has physical existence are known as Tangible or Concrete entities. Eg. Book,
employee, car etc.
Non Tangible Or Abstract Entity:-
Those entities which has conceptual existence are known as non tangible or abstract entities. Eg.
Event, job etc.
Attribute:-
An attribute is a property of an entity or a relationship type. An entity is described using a set of
attributes. All entities in an entity set have similar attributes i.e. It is a property used to describe the
specific features of the entity. So we can say attributes are the properties of an entity that
characterize and describe it. Eg. student entity can be described by rollnumber, name, age, address,
course etc.
Entity Type:-
Collection of entities that share the same attributes but different values is known as entity type.
Instance:-
A specific occurrence of an entity type is known as instance. Eg. Instances of entity student may be
Amit, Akshay, Krish, Harshit, Ritish, Utkarsh etc. S.P. Chauhan 8
Entity - Relationship Model
Entity Set:-
An entity set is a set of same entities that have same properties or attribute i.e. collection of similar
kind of entities. i.e. collection of instances of a particular entity.
Key:-
It is an attribute or a set of attribute used to identify a particular entity in an entity set or particular
instance in an entity set. It is also called super key.
Strong Entity Set:-
Those entity set which contains a key attribute i.e. contain key is called strong entity eg. In student
entity set roll number can be key attribute so this entity set is strong entity set.
Weak Entity Set:-
Those entity set which does not contain key attribute are called weak entity set. A weak entity can be
identified uniquely only by considering some of its attribute in conjunction with the key attribute of
another entity, which is called identifier owner or parent entity. Following restriction must hold for
weak entity set.
i. The owner entity must hold for weak entity in one to many/many to many relationship set.
ii.The weak entity must have total participation in the identifying relationship.
Domain of Attribute (Domain):-
Each simple attribute of an entity type contains a possible set of values that can be given to it. This
set of values is called domain of attribute. An attribute can not contain values outside this domain.
S.P. Chauhan 9
Entity - Relationship Model
• Types of Attribute:-
i. Simple Attribute:-
It consist of single component with independent existence i.e. It can not be feather divided into
smaller component. It is also called atomic attribute eg. roll no & age etc.
ii.Composite Attribute:-
Those attribute which can be further divided into two or more attribute are called composite
attribute eg. Name can be divided into first name, mid name & last name.
iii.Single Valued Attribute:-
Those attributes which holds a single value for each occurrence of an entity type eg. employee_id,
age.
iv.Multivalued Attribute:-
Those attributes which can have more than one value for a particular entity eg. Phone Number,
skills etc.
v.Stored Attribute:-
Those attribute which are directly stored in database eg. Date of birth.
vi.Derived Attribute:-
Those attributes which are not stored directly but can be derived from stored attribute eg. Total
marks, age of person, total salary etc.
S.P. Chauhan 10
Entity - Relationship Model
• Types of Attribute:-
vii. Identifier/ Key Attribute:-
One or more attribute used to identify the instances of entity set uniquely.
viii.Descriptive Attribute:-
A relationship may have attribute this is called descriptive attribute.
Date
viii.Complex Attribute:-
Those attributes that are formed by arbitrarily nesting the composite and multivalued attribute. Eg.
Address-Phone.
S.P. Chauhan 11
Entity - Relationship Model
• Relationship:-
It is defined as connection or association between two or more entities i.e. It is rule of communication
between two or more entities. A relationship describe how two or more entities are related to each
other. The entities that participate in relationship are known as participants.
A relationship has no physical or conceptual existence but depends upon the association between
entities. A particular occurrence of relationship between individual entity instances is called
Relationship Instance OR Relational Occurrence. A set of same type of relationship is called
relationship set. Relationship can be described as follows:
Degree of Relationship.
Identifying Relationship.
Cardinality of Relationship/ Connectivity of Relationship/ Types of Relationship Cardinality/
Mapping Cardinality/ Cardinality Ratio/ Types of Relationship.
Existence of a Relationship.
n – array Relationship.
S.P. Chauhan 12
Entity - Relationship Model
• Degree of Relationship:-
It is defined as the number of entities associated with the relationship i.e. Degree of relationship are
numbers of entities participating in a relationship set. Following are the types of degree of relationship.
i. Recursive or Unary Relationship:-
It is the relationship between the instances of a single entity set i.e. where same entity set is
associated more than once in different role. Thus in this relationship entity relates only to other
instance of its own type i.e. when single entity set participate in relationship set but in different role.
E.g.
Employee
Role
Managed By Manager
Manages
ii. Binary Relationship:-
Association between two entities is called binary relationship. These are very common relationship
& its degree will be 2. Eg.
College Has Principle
iii. Ternary Relationship:-
It is an association among three entities & its degree will be 3. Eg.
Skills Uses Person
Project
S.P. Chauhan 13
Entity - Relationship Model
• Identifying Relationship:-
The relationship between weak entity type and it identifying /own / strong entity type is known as
identifying relationship of weak entity type. Eg.
Employee Has Dependents
S.P. Chauhan 15
Entity - Relationship Model
• Types of Relationship Cardinality/ Cardinality Constraints/ Mapping Cardinality/ Cardinality
Ratio/ Types of Relationship/ Connectivity of Relationship:-
iv. Many – to – Many:-
In this cardinality one instance of entity set ‘A’ can associate with any number of instances of entity
set ‘B’ and an instance of entity set ‘B’ can associate with any number of instance of entity set ‘B’
via relationship. Eg.
M N
Books Written By Authors
Many Many
A book can be written by any number of author
and an author can write any number of books.
• Existence of Relationship:-
In this case existence of entities depends on the existence of another entity i.e. Existence of an entity
in a relationship is defined as either mandatory or optional or unknown. In mandatory an occurrence
of either the one or many side entity must always exist for the entity to be included in relationship. It
is defined by a placing perpendicular lines to the connection line between entity & relationship. In
Optional the existence of entity need not exists and is defined by placing letter 0 (zero) and a line
perpendicular to the connection line between an entity & relationship. In unknown neither mandatory
nor optional but minimum connectivity is assumed to be one. As shown in fig.
S.P. Chauhan 16
Entity - Relationship Model
• Existence of Relationship:-
As shown in fig.
Mandatory Optional Unknown
Relationship Relationship Relationship
---- ----
S.P. Chauhan 17
Entity - Relationship Model
• n – ary Relationship:-
When a large number of entity sets are participating in a relationship, then such type of relationship
is called an n-ary relationship. In this case a single relationship with n-connection one to each entity.
Person Admitted
Hospital
to
6. Composite Attribute Is a
12. : Total Generalization
S.P. Chauhan 20
Entity - Relationship Model
• Symbols OR Notations Used in Entity – Relationship (E – R) Diagram:-
S.No. Symbol Description
S.No. Symbol Description
Specialization or 20. E1 R E2
13. Is a :
Generalization Total Participation of E2 in R
21. E1 R E2
14. Is a : Disjoint Generalization
Partial participation of E2 in R
Disjoint
22. : Discriminating Attribute
15. : Optional One
0 |
23. : Derived Attribute
16. : Mandatory One
| |
17. 0 : Optional Many
S.P. Chauhan 22
Entity - Relationship Model
• E –R Diagram of college database :-
Make the E-R diagram of college database with following considerations.
Roll No
Address
Student Name
Course_Duration Course_Id
Course
Course_Name
Address Faculty_Id
Faculty
Basic_Salary Faculty_Name
Name
Address Guardian
Age S.P. Chauhan 23
Entity - Relationship Model
• E –R Diagram of college database :-
Make the E-R diagram of college database with following considerations.
Address Course_Duration
Address Roll No Course_Name
N 1
Student Opt Course Course_Id
N N
N N
Has Enrolled In Conducted By
Name
M
Taught By
1 1
Age Guardian M Faculty_Id
Address 1 N Faculty_Name
Department Works In Faculty
Address
1 1
Department_Id Head of Basic_Salary
Department_Name
Date From S.P. Chauhan 24
Entity - Relationship Model
• E –R Diagram of college database :-
Relationships of E – R Diagram of college database.
i. Head – of :- It is a one to one (1:1) relationship between faculty & department entity sets. Here
participation of faculty is partial as all faculty can not be head of the department, while
participation from department side it is total. As each department has one head.
ii. Works in :- It is one to many (1:N) relationship between department & faculty entity sets because
one faculty is assigned one department but a department can have many faculties. In this
relationship participation from both side is total. As every faculty is assigned some department and
every department have some faculties.
iii. Opts:- It is one to many (1:N) relationship between course and student entity sets, as one students
will opt one course but a course can be opt by many students. In this relationship participation from
student is total because all student must opt a course. But participation from course is partial as
there can be any course which is not opt by any student.
iv. Taught. By:- It is many to many (M:N) relationship between entity sets Faculty & Course, as a
faculty can teaches many course and a course can be taught by many faculties.
v. Enrolled:- It is many-to-one (M:1) relationship between entity sets Student & Department. As a
student can enrolled in one department but a department can have many students. In this
relationship student has total participation because every student must enroll department, but
department has partial participation because there can be some department in which no student
enrolled. S.P. Chauhan 25
Entity - Relationship Model
• E –R Diagram of college database :-
Relationships of E – R Diagram of college database.
vi. Conducted By:- It is many-to-one (M:1) relationship between entity sets Course & Department. As
a department can organized many course but a course can belong to one department. In this
relationship both entity sets course & department has total participation because every department
is conducting a course and each course belong to some department.
vii.Has:- It is Many to Many (1:N) relationship between entity sets Student & Guardian as a student
can have more then one local guardian and one local guardian can relate to more then one student
only. Here weak entity guardian has total participation in relationship set ‘Has’, as there may be
some students who have no local guardian but every member of entity set guardian will associate
with some student.
S.P. Chauhan 26
Entity - Relationship Model
• E –R Diagram for a Company:-
Make the E-R diagram for a company with following considerations.
i. Company organized into departments. Each department has unique name and a particular
employee who manages the department. Start date for the manager is recorded. Department may
have several locations
ii. Department control a number of projects. Project has unique name, number and a single location
and description.
iii. Company’s employee information consists of unique id, name, address, salary, gender, and birth
date. An employee is assigned to one department, but may work for several projects (may be
controlled by other departments). Number of hours/week an employee works on each project is
recorded. The person who supervise the employee is also employee of company.
iv. Employee dependents are also tracked for health insurance purpose which consists of dependent
name, birth date, relation to employee.
S.P. Chauhan 27
S.P. Chauhan 28
Entity - Relationship Model
• E –R Diagram :-
Make the E-R diagram for National Hockey League (NHL) with following considerations.
i. The NHL has many teams. Each team has unique name, coach, city and one player of team is
appointed as captain of team.
ii. Each player has a name, unique id, position such as goal keeper. Information about injury is also
kept with players which consists of injury type, injury id and date.
iii. Each player belongs to only one team
iv. Game is played between two teams while playing a game date and score is also recorded.
S.P. Chauhan 29
Enhanced Entity - Relationship (EER) Model
• Enhanced E –R OR EER Model:-
This model includes all basic concepts of E-R model with additional concepts such as
subclass/super class, Attribute inheritance and specialization/generalization. The resulting model
with these concepts is called Enhanced – ER or Extended E-R model
Sub Class:-
It is group of entities in an entity set that share same attribute/property of entity set and
relationship but distinct from other group of entities. Here objects or instances or entities in one
entity set are subdivided into one or more sub group based on some condition. These sub group
are called sub classes. These sub groups may then be treated differently in certain circumstances.
Super Class:-
It is an entity set that has a relationship with one or more distinct subclass of its own. Each
member of sub class is also a member of super class. This means, the sub class member is same
as the entity in super class but has a distinct role. The relationship between sub & super class is
generally one-to-one (1:1). But in some case a super class can have overlapping subclass.
Eg. - Let us consider entity set PERSON it can be sub grouped into MANAGERS, ENGINEERS
TECHNICIAN, SECRETERY. These sub groups of entity set PERSON are called sub class and
PERSON is called super class
S.P. Chauhan 30
Enhanced Entity - Relationship (EER) Model
• Enhanced E –R OR EER Model:- The relation between sub class & super class is
Person called super class/subclass relationship. It is also
called “IS-A” or “IS-AN” relationship.
Any entity of sub class represent the same real
IS-A IS-AN IS-A world entity as that of super class.
Any entity of subclass must be a member of super
class.
Manager Engineer Secretary
It is not necessary that an entity of super class be a
member of some subclass.
Notation of Sub Class & Super Class:-
IS-AN IS-A IS-AN
The super class is connected with a line to a circle.
Then circle is connected by line to each sub class.
Electrical Computer Electronic The U shaped symbol is placed on each line that
Engineer Engineer Engineer connect a sub class to circle, it indicate that sub
class is a sub set of super class and attribute of
super class will be shared by all entities of sub
class, but the attribute that are unique to a
particular sub class are associated with respective
sub class. As shown in fig. S.P. Chauhan 31
Enhanced Entity - Relationship (EER) Model
• Notation of Sub Class & Super Class:- Condition for using Supertype/ Subtype
Super Class Shared Relationship:-
Attributes The supertype/ subtype relationship should be used
when either or both of the following conditions
satisfied:
i. There are attributes that are common to some (but
not all) of the instances of an entity type.
ii. The instance of subtype participate in a
relationship unique to that subtype.
Sub Class 1 Sub Class 2 Sub Class 3 Advantage of using Superclass & Subclass:-
i. It avoids the need to describe similar concepts
more than once thus saving time for data
Unique Unique Unique modeling.
Attributes Attributes Attributes ii. Result in more readable and better looking E-R
diagram.
iii. Superclass & Subclass relationship add more
content and information to design.
S.P. Chauhan 32
E_DOB
Enhanced Entity - Relationship (EER) Model
E_name Attribute Inheritance:-
E_id Employee It is the property by which an entity which is
E_Address member of sub class inherits all attributes of its super
class. This feature is used avoid redundancy. The
Entity also inherit all relationship in which super
class participates. Because an Entity in subclass
represent same real world entity as in super class.
Here subclass with its own attributes and relationship
& with all attribute & relationship it inherits from
Part Time Full Time Consultant super class can be considered as an entity of its own
right. In the example Part time, full time &
consultant subclasses will also have all attributes of
Hourly Salary employee superclass.
Rate Per
Rate Visit A subclass with more then one superclass is called a
Allowances
shared subclass. In this case subclass inherits
attributes of all superclasses also may have it own
additional attributes. This is referred as Multiple
inheritance or Specialized/ Generalized lattice.
S.P. Chauhan 33
Enhanced Entity - Relationship (EER) Model
• Specialization:-
It is the process of identifying the sub set of an entity set that share some unique but distinguishing
characteristics. So it maximizes the difference between members of an entity set by identifying the
unique but distinguish characteristics of each member. In other words we can say it is the process of
defining a set of subclasses of a superclass based on some distinguish characteristics of entities in the
super class. Specialization is a top down process of defining first superclass and their related subclasses.
E_DOB E_name
Hourly
Allowances Employee
Rate
E_DOB E_Address
E_id
E_name
E_id Employee
E_Address
Salary
Rate Per
Visit Part Time Full Time Consultant
Model
Max Speed No. of Passengers Route No.
Three Capacity
Route No. No. of Axel
Price Wheeler
Reg. No.
V_Id Entity Set after Generalization
S.P. Chauhan 35
Enhanced Entity - Relationship (EER) Model
• Constraints of Specialization/Generalization:-
Constraints that can be placed on generalization and specialization are as follows:
i. Predicate Defined (Condition Defined):- ii. Attribute Defined Specialization:-
In condition defined the membership of entities If have membership condition defined on same
in subclass is determined by placing a condition attribute of super classes called attribute
on the value of some attributes of superclass. defined specialization. The common attribute
No. of Passengers No. of Axel that defined condition is called defining
Max Speed Model attribute of specialization. Category
Book Title
Reg. No. Vehicle V_Id Price
Price Pages Book
Year
Route No. ISBN
Capacity
Category
Social
Politician
Worker
S.P. Chauhan 37
Enhanced Entity - Relationship (EER) Model
• Constraints of Specialization/Generalization:-
iv. Participation/ Completeness Constraint:- v. Disjoint Constraint:-
b) Partial Participation:- It specifies that every It is only applied when a super class has more
entity or member of super class need not then one subclasses. It specifies that an entity
belongs to any of its subclasses of or member or instance of super can be a
specialization/ generalization. It is member of at most one of the subclass in
represented by putting single line connecting specialization/generalization. It is represented
the super class with circle. It is also called by placing letter ‘d’ in circle.
Partial Specialization.
Employee
Employee
d
S.P. Chauhan 38
Enhanced Entity - Relationship (EER) Model
• Constraints of Specialization/Generalization:-
vi. Overlapping Constraint:- Similarly we can have
It specify that an entity or member or instance vii. Disjoint Total Constraint:-
of super class can be member of one or more viii. Disjoint Partial Constraint:-
subclass of the specialization/generalization. It ix. Overlapping Total Constraint:-
is denoted by placing letter ‘O’ in circle.
x. Overlapping Partial Constraint:-
Employee
S.P. Chauhan 39
Enhanced Entity - Relationship (EER) Model
• Aggregation:-
As E-R diagram represents the relationship between two or more entities and it does not represent
relationship among relationships. It can be represented using aggregation. “Aggregation is the
process through which a relationship can be treated as higher level entities i.e. aggregation allow us
to indicate that a relationship set can participate in other relationship set as an entity set.
S.P. Chauhan 40
Enhanced Entity - Relationship (EER) Model
• Categorization:-
It is the process of modeling a single subclass with a relationship that involves more than one
distinct superclasses.
Employee Department Company
Owner
In above example let us assume that a vehicle is purchased by a company for the transportation
from one department to other. Now the owner of the vehicle can be a department or an
employee or the company itself. Such is an case of modeling in which one subclass have
relationship with more than one super class.
S.P. Chauhan 41