Database Design Using ER Model (14M)

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 107

Chapter 3

Database Design using


ER Model (14M)
Types of Database Models
Entity Relationship Model
(ER-Model)
Entity Relationship Model(ER-Model)

• The Entity Relationship Model(ER-Model) is a high level


conceptual data model developed by Chen in 1976 to
facilities database design.

• The overall logical structure (Schema) of a database


can be expressed graphically by an ER diagram.

• The Entity Relationship Model(ER-Model) is a design


tool. It is a graphical representation of the database
system which provides a high level conceptual(Logical)
data model and supports the user’s perception of the data.
• The basic constructs of  ER Model are Entity,
Attributes and Relationships.
Components
of ER Model
• Rectangle – It represents entity in the ER Model.
• Ellipse – It represents attribute in the ER Model.
• Diamond – It represents relationship between entity and attribute.
• Line –It links attribute to entity set and entity set to relationship se
• Doubles Ellipses – It represents multivalued attributes.
• Dashed Ellipses – It denotes derived attributes.
• Double lines – It indicates total participation of an entity in a
relationship set.
• Double Rectangle – It represents weak entity set.
• Double Diamonds – It represents weak relationships.
• Multiple ellipses connected to single ellipse using lines –
It represents composite attribute.
• Ellipse with line inside it – It represents single values attributes
Entities
• An Entity is a thing or object in the real world that is
distinguishable from all other objects.
• For example 'Person' in an organization is an entity.
Customer in the bank.
Student in the college etc
• An Entity may be a person, book, loan table. etc
• An entity has a set of properties. Individual objects are
called Entities.
Notation:
• Entities are represented by rectangles containing the
entity name in ER Model.

Entity Name

Example

Student
Entity Set
• Groups of the same type of objects are called Entity Types
or Entity Set.
• All Entities in an Entity set have the same set of
attributes.

• Thus entity set is a set of entities of the same type that


share the same properties or attributes. The set of all
person who are customer at a given bank.
Notation: In ER diagram Entity Set is represented as

Entity Name Entity Type

E1

E2
Entity Set
E3

Eg: E1 is an Entity having Entity Type Student and


Set of all student is called Entity Set.
Example
Attributes
• An entity is represented by a set of attributes. It
corresponds to a field in a table.
Notation
• Attributes are represented by ovals and are connected to
the entity with a line in ER model. Each oval contains the
name of the attribute it represents.

Attribute Name
Example

Student
Roll no Year
name

Student
Example
 

Consider the following Student table-

Roll_no Name Age


1 John 20
2 Rahul 19
3 Smith 20
4 Ajay 19

Student

This complete table is referred to as “Student Entity Set” and each row
represents an “entity”.
Representation as ER Diagram-

The above table may be represented as ER


diagram as-
Domain or Value Set
For each attribute there is a set of permitted
values called the domain or value set of the
attribute.
Types of Attributes

In ER Model attributes can be classified into the


following types.

• Simple and Composite Attribute


• Single Valued and Multi Valued attribute
• Stored and Derived Attributes
• Null Attribute
1) Simple and Composite Attribute

• Simple Attribute that consist of a single atomic


value. A simple attribute cannot be subdivided.
For example the attributes age, roll_no etc are
simple attributes.

• A Composite Attribute is an attribute that can


be further subdivided. For example the attribute
ADDRESS can be subdivided into street, city,
state, and zip code. 
• Simple Attribute:
Attribute that consist of a single atomic value.
Example: Salary, age etc

• Composite Attribute :
Attribute value not atomic.
Example : 
Address : House_no:City:State
Name : First Name: Middle Name: Last Name
Example
2) Single Valued and Multi Valued attribute

• A Single Valued attribute can have only a


single value. For example a person can have only
one 'date of birth', 'age' , Adhar card no.,Passport
no etc
• Multivalued attributes can have multiple values.
For instance a person may have multiple phone
numbers, multiple degrees etc.
Notation:
Multivalued attributes are shown by a double line
connecting to the entity in the ER diagram
• Single Valued Attribute:
Attribute that hold a single value.
Example1: Age
Exampe2: City
Example3:Customer id

• Multi Valued Attribute:


Attribute that hold multiple values.
Example1: A customer can have multiple phone
numbers, email id's etc
Example2: A person may have several college
degrees
Example

Single Valued
Attribute

Multi Valued
Attribute
3) Null Attributes
• Null value is used when an entity does not have a
value for an attributes.
• Null can also designate that an attribute is
unknown i.e missing or not known.

Roll no

Student
4) Stored and Derived Attributes
• The value for the derived attribute is derived from the
other attribute.
• For example 'Date of birth' of a person is a attribute. The
value for the attribute 'AGE' can be derived by subtracting
the 'Date of Birth'(DOB) from the current date.
• Stored attribute supplies a value to the related attribute.
Notation:
5) Derived Attribute:
An attribute that’s value is derived from a other
attribute.

Example: age, and it’s value is derived from the


attribute Date of Birth.
Example
Key Attribute
• The attribute which uniquely identifies each
entity in the entity set is called key attribute. For
example, Roll_No will be unique for each
student.
Notation:
• In ER diagram, key attribute is represented by an
oval with underlying lines.
Relationships
• A Relationship is an association between several entities.
• A relationship type represents the association between
entity types.

Notation:
Relationships are represented by a diamond connected to the
related entities in ER Model.
Example
• For example, ‘Enrolled in’ is a relationship type
that exists between entity type Student and
Course.
Example
Relationship Set
• A set of relationships of same type is known as relationship set.
• The following relationship set depicts S1 is enrolled in C2, S2
is enrolled in C1 and S3 is enrolled in C3.
Degree of a relationship set:
The number of different entity sets participating in
a relationship set is called as degree of a
relationship set.
1) Unary Relationship
When there is only ONE entity set participating in a
relation, the relationship is called as unary relationship.
For example, a person is married to only one person.
2) Binary Relationship

When there are TWO entities set participating in a


relation, the relationship is called as binary relationship.
For example, Student is enrolled in Course.
3) Ternary Relationship

When there are THREE entities set participating in a


relation, the relationship is called as ternary relationship.
4) n-ary Relationship

When there are n entities set participating in a relation, the


relationship is called as n-ary relationship.
Entity / Entity Set types
• An entity set is a set of same type of entities.
• An entity refers to any object.
• An entity set may be of the following two
types-

1) Strong entity set


2) Weak entity set
1) Strong Entity Set

• Strong Entity Set is an entity set that contains


sufficient attributes to uniquely identify all its
entities.
• In other words, an entity set that has a primary key
is called ‘Strong Entity Set’.
Notation:
• It is represented using a single rectangle.

Entity Name
2) Weak Entity Set

• A Weak Entity Set is an entity set that does not contain sufficient
attributes to uniquely identify its entities.
• In other words, a primary key does not exist for a weak entity set.
• However, it contains a partial key called as a discriminator.
• Discriminator can identify a group of entities from the entity set.
• Discriminator is represented by underlining with a dashed line.
Notation:
• It is represented using a double rectangle.

Entity Name
In ER diagram, weak entity set is always present in
total participation with the identifying relationship
set.
Conclusion

Primary Key Discriminator


Differences between Strong entity set and Weak entity set-
Strong Entity Set Weak Entity Set
1) A single rectangle is used for the 1) A double rectangle is used for the
representation of a strong entity set. representation of a weak entity set.
2) It contains sufficient attributes to form 2) It does not contain sufficient attributes
its primary key. to form its primary key.
3) A double diamond symbol is used for
3) A diamond symbol is used for the
the representation of the identifying
representation of the relationship that
relationship that exists between the strong
exists between the two strong entity sets.
and weak entity set.
4) A double line is used for the
4) A single line is used for the
representation of the connection between
representation of the connection between
the weak entity set and the relationship
the strong entity set and the relationship.
set.
5) Total participation may or may not 5) Total participation always exists in the
exist in the relationship. identifying relationship.

6) Eg: 6) Eg:
Mapping Cardinality Constraints / Ratios (M:N)

• Cardinality: Total number of records from a relation is


called as cardinality of a relation.
• For eg : If there are three records in relation student then
cardinality of relation student is 3.
• E-R data model defines certain constraints to which the
data in the database must satisfy. These constraints are
called MAPPING CARDINALITIES. Mapping
Cardinalities are useful in describing the binary
relationship sets.
Mapping Cardinality Constraints / Ratios
(M:N)
1) One-to-One Cardinality
• An entity in set A can be associated with at most one
entity in set B.
• An entity in set B can be associated with at most one
entity in set A.
Notation:
Example

• One student can enroll in at most one course.


• One course can be enrolled by at most one student.
2) One-to-Many Cardinality

• An entity in set A can be associated with any number


(zero or more) of entities in set B.
• An entity in set B can be associated with at most one
entity in set A.
Notation:
Example

• One student can enroll in any number (zero or more)


of courses.
• One course can be enrolled by at most one student.
3) Many-to-One Cardinality

• An entity in set A can be associated with at most one


entity in set B.
• An entity in set B can be associated with any number
(zero or more) of entities in set A.
Notation:
Example

• One student can enroll in at most one course.


• One course can be enrolled by any number (zero or
more) of students.
4) Many-to-Many Cardinality

• An entity in set A can be associated with any number


(zero or more) of entities in set B.
• An entity in set B can be associated with any number
(zero or more) of entities in set A.
Notation:
Example

• One student can enroll in any number (zero or more) of


courses.
• One course can be enrolled by any number (zero or more)
of students.
Enhanced Entity Relationship
Model (ER-Model)
OR

Extended Entity Relationship


Model (ER-Model)
Extended Entity Relationship Model (ER-Model)

• EER is a high-level data model that incorporates


the extensions to the original ER model.

It is a diagrammatic technique for displaying


the following concepts
• Sub Class and Super Class
• Specialization and Generalization
• Aggregation
Features of EER Model

• EER creates a design more accurate to database schemas.


• It reflects the data properties and constraints more
precisely.
• It includes all modeling concepts of the ER model.
• Diagrammatic technique helps for displaying the EER
schema.
• It includes the concept of specialization and
generalization.
• It is used to represent a collection of objects that is union
of objects of different of different entity types.
1) Generalization
• Generalization is the process of generalizing the entities
which contain the properties of all the generalized entities.

• It is a bottom approach, in which two lower level entities


combine to form a higher level entity.

• Generalization is the reverse process of Specialization.

• It defines a general entity type from a set of specialized


entity type.

• It minimizes the difference between the entities by


identifying the common features.
In the above example, Tiger, Lion, Elephant can all be generalized
as Animals.
Fig : Specialization and Generalization
2) Specialization
• Specialization is a process that defines a group entities
which is divided into sub groups based on their
characteristic.

• It is a top down approach, in which one higher entity


can be broken down into two lower level entity.

• It maximizes the difference between the members of an


entity by identifying the unique characteristic or
attributes of each member.

• It defines one or more sub class for the super class and
also forms the superclass/subclass relationship.
In the above example, Employee can be specialized as Developer
or Tester, based on what role they play in an Organization.
Summary
• Generalization is a process of forming a generalized super
class by extracting the common characteristics from two or
more classes.

• Specialization is a reverse process of generalization where


a super class is divided into sub classes by assigning the
specific characteristics of sub classes to them.
3) Aggregation
• Aggregation is a process that represent a relationship
between a whole object and its component parts.

• It abstracts a relationship between objects and


viewing the relationship as an object.

• It is a process when two entity is treated as a single


entity.
In the above example, the relation between College and Course is
acting as an Entity in Relation with Student.
Comparison between Generalization and Specialization

Generalization Specialization
1) It proceeds in a bottom-up manner. 1) It proceeds in a top-down manner.

2) Generalization extracts the common 2) Specialization splits an entity to form


features of multiple entities to form a new multiple new entities that inherit some
entity. feature of the splitting entity.

3) The higher level entity must have lower 3) The higher level entity may not have
level entities. lower level entities.

4) Generalization reduces the size of a 4) Specialization increases the size of a


schema. schema.

5) Generalization entities on group of entities. 5) Specialization is applied on a single entity.

6) Generalization results in forming a single 6) Specialization results in forming the


entity from multiple entities. multiple entity from a single entity.
Examples of ER
diagram
Bank Management
System
Hospital Management
System
Library Management
System
College Management
System
Railway Reservation
System
Airline Reservation
System
Construct an E-R diagram for a car insurance company
whose customers own one or more cars. Assume suitable
attributes.(W-18)
Draw ER diagram for Banking system, to represent a customer
has account scenario. Identify entities with their attributes and
draw a diagram. (W-18)
5) Draw Enhanced ER diagram for loan payment system.
Consider following entities: (W-18)
(i) Loan (Loan_id, Loan_amount, Loan_date)
(ii) Payment (Payment_id, Payment_date, Balance_amount)
(iii) Personal Loan (Personal Loan_no, Interest rate)
(iv) Home Loan (Home loan_no, Interest rate)
Draw ER diagram of library management system
in which library maintain the data of books,
borrowers, issue return details, fine collection,
supplier of books etc. Assume suitable data and
display the relationship among entities.(S-19)
Draw enhanced ER diagram for loan payment system.
Consider the following entities:
(i) Loan (Loan_id, Loan_amount, Loan_date)
(ii) Payment (payment_id, Payment_date, Balance_amount)
(iii) Personal Loan (Personal Loan_no, Interest rate)
(iv) Home Loan (Home Loan_no, Interest rate)

Show strong entity set, weak entity set, super class and sub
class. (S-19)
Draw the enhanced E-R diagram for College
Management System and show strong entity set,
weak entity set, super class and sub class.(W-19)
Winter-18
1) Draw and name 4 symbols used in ER diagram. (2M)
2) Construct an E-R diagram for a car insurance company whose
customers own one or more cars. Assume suitable attributes. (4M)
3) Draw ER diagram for Banking system, to represent a customer
has account scenario. Identify entities with their attributes and
draw a diagram. (6M)
4) For each of following relationship indicate type of relationship
(1:1, 1:m, m:m) (i) Works in (a relationship between entities dept.
and staff) (ii) Managers (a relationship between entities employee
and Manager) (4M)
Winter-18
5) Draw Enhanced ER diagram for loan payment system.
Consider following entities: (6M)
(i) Loan (Loan_id, Loan_amount, Loan_date)
(ii) Payment (Payment_id, Payment_date, Balance_amount)
(iii) Personal Loan (Personal Loan_no, Interest rate)
(iv) Home Loan (Home loan_no, Interest rate)
Summer-19

1) List and draw any four symbols used in ER Model.(2M)


2) Describe enhanced ER model with the help of example.(4M)
3) Explain different types of attributes.(4M)
4) Draw ER diagram of library management system in which
library maintain the data of books, borrowers, issue return
details, fine collection, supplier of books etc.
Assume suitable data and display the relationship among
entities.(6M)
Summer-19
Draw enhanced ER diagram for loan payment system.
Consider the following entities:
(i) Loan (Loan_id, Loan_amount, Loan_date)
(ii) Payment (payment_id, Payment_date, Balance_amount)
(iii) Personal Loan (Personal Loan_no, Interest rate)
(iv) Home Loan (Home Loan_no, Interest rate)

Show strong entity set, weak entity set, super class and sub
class.
Winter-19
1) Explain Generalization with example.(4M)
2) Explain different types of attribute with example and
their symbols used in ER diagram. (4M)
3) Draw the symbols used for entity relationship diagram
and write their meaning. (4M)
4) Identify entities and their relationship in terms of tables
for railway reservation system.(6M)
5) Draw the enhanced E-R diagram for College
Management System and show strong entity set, weak
entity set, super class and sub class.(6M)

You might also like