ERD
(Entity Relationship
Model)
1
Data
Models
⚫ A data model defines how a database logically structures and
organizes data
⚫ Data Models are fundamental entities to introduce
abstraction in a
DBMS.
⚫ Data models define how data is connected to each other and
how
they are processed and stored inside the system.
⚫ The very first data model could be flat data-models, where
all the data used are to be kept in the same plane. Earlier data
models were not so scientific, hence they were prone to
introduce lots of duplication and update anomalies.
Entity-Relationship
Model
⚫ Entity-Relationship (ER) Model is based on the notion of real-
world entities and relationships among them.
⚫ While formulating real-world scenario into the database
model, the ER Model creates entity set, relationship set,
general attributes, and constraints.
⚫ ER Model is best used for the conceptual design of a database.
⚫ ER Model is based on:
 Entities and their attributes.
 Relationships among entities.
ER
Model
Entity
⚫ An entity in an ER Model is a real-world entity that has
independence
existence.
Attribute:
⚫An entity in an ER Model having properties called
attributes. Domain
⚫ Every attribute is defined by its set of values called
domain.
⚫ For example, in a school database, a student is
considered as an entity.
ER
Model logical association among entities is
called
⚫ Relationship
The
relationship.
⚫ Relationships are mapped with entities in variousways.
Mapping cardinalities define the number of association between
two entities.
⚫ Mapping cardinalities:
⚫ o one to one
⚫ o one to many
⚫ o many to one
⚫ o many to many
Relational
Model
⚫ The most popular data model in DBMS is the Relational Model.
It is
more scientific model than others.
⚫ This model is based on first-order predicate logic and defines a
table as an n-ary relation.
Table in relational
Model
ER
Model
The main highlights of this model are:
⚫Data is stored in tables called relations.
⚫Relations can be normalized.
⚫In normalized relations, values saved are atomic
values.
⚫Each row in a relation contains a unique value.
⚫Each column in a relationcontainsvaluesfrom a
same domain.
Entity Relationship Model
9
⚫Entity Relationship is a logical representation of data
in an organization.
⚫It views the entire system as a collection of entities
related to another.
⚫It is used to describe the elements of a system and
their relationships.
⚫It was introduced by Peter Chen in 1976.
Advantages of E-R Model
10
Some important advantages of E-R model are as follows:
1. Conceptual Simplicity
ER model represents the concept of a database along with its
entities and a relationship in an easy way. It becomes easier to
create and manage the complex database designs by using E-R
model.
2. Visual Representation
E-R model provides a visual representation of data and the
relationships among data. It enables database designers,
programmers and end users to understand database easily.
Advantages of E-R Model
11
3. Effective Communication Tool
The database designer can use E-R model to get different views
of data as seen by programmers, managers and end users etc. E-
R model works as an effective communication tool to integrate
these views.
4. Integrated with relational database
E-R model is well integrated with the relational database
model. This
integration makes relational database design a very structured
process.
Elements of ERD
12
Different elements of an E-R
Model:
⚫ Entities
⚫ Attributes
⚫ Relationships
Entities
13
⚫ An entity is a person, place, thing or event for which data is
collected and maintained.
For Example:
⚫ A library system may contain data about different entities like
BOOKS and MEMBER.
⚫ A college system may include entities like STUDENT, TEACHER
and
CLASS etc.
Entities cont.…
14
Some examples of entities
⚫ Person: TEACHER, PLAYER, DOCTOR
⚫ Place: COUNTRY, CITY
⚫ Object: VEHICLE, TOY, FURNITURE
⚫ Event: PURCHASE, ADMISSION, REGISTRATION
⚫ Concept: ACCOUNT, PROGRAMMING
An entity is represented by rectangle. The name of the entity is
written
inside the rectangle.
Entities Cont.…
15
The entity is used in three different meanings that are as
follows:
⚫ Entity Type
⚫ Entity Instance
⚫ Entity Set
Entities
Type
16
⚫ A set of entities with the same attributes is called entity type.
⚫ All entities in an entity type share common
characteristics. It is
Also known as entity class.
⚫ For Example:
⚫ STUDENT entity class is a set of all students.
⚫ Similarly, BOOK entity type is a collection of all books etc.
Entities
Instance
17
⚫ A member of an entity class is known as an Entity Instance.
⚫ Each entity instance of an entity type has its own value for
each instance.
For Example:
⚫ A student Ali of STUDENT entity type is an entity instance.
Entity Set
18
⚫ A set of all entities of a particular entity type in the
database at a given point of time is called an Entity Set.
For Example:
⚫ An entity set Student may consist of all students in the
university.
⚫ Another entity set Teacher may consist of all teachers
in the university etc...
⚫ The same name is usually used for both entity type and
entity set. For example BOOKS refers to both a entity type
and as well as the current set of all books in the database.
Attribute
s
19
⚫ The characteristics of an entity are called attributes or
properties.
⚫ For Example: Name, Address, Class and Email of a student
are his
attributes.
⚫ All instances of a particular entity class have same
attributes. For Example, all students of STUDENT entity
class have the attributes of Names, Address, Class and Email.
Attribute Domain
20
⚫ An attribute domain is a set of possible values for an
attribute. All attributes have domain. The domain may consist
of a range of values or some discrete values.
For Example:
⚫ The domain for Grade Point Average (GPA) can be from 0 to 4.
⚫ Similarly, the domain for Gender attribute can be Male or
Female.
Attribute Domain cont..
21
⚫ The association of a domain with an attribute ensures the
integrity of database. The domain is normally defined in
form of data type and some additional constraints like range
constraint.
For Example:
⚫ If the data type of a field is integer, it can store only integer
values.
Relationships
22
⚫ A relationship is a logical connection between different entities.
⚫ The entities that participate in a relationship is called
participants.
⚫ The relationship may be between different entities or between
an entity
and itself.
⚫ A relationship is established on the basis of interaction among
these entities.
For Example:
⚫ A relationship exists between a STUDENT and TEACHER
because
Relationships cont…
23
⚫ A relationship is called Total if all entities of that entity set
may be participant in the relationship.
⚫ A relationship is called partial if some of the entities of that
entity set may be participant in the relationship.
⚫ Suppose : A relationship SUPP_Part exists between
Supplier and PART.
⚫ The relationship is total if every part is supplied by a
supplier. The
relationship is partial if certain parts are available without a
supplier.
24
E-R Diagram
25
⚫ E-R diagram is a graphical Representation of E-R model using
a set of standard symbols. Different symbol used in E-R
diagram are as follows:
26
Types of Attributes
27
Different types of attributes are represented in E-R diagram as
follows:
1. Simple Attribute
2. Composite Attribute
3. Single-Valued Attribute
4. Multi-Valued Attribute
5. Stored Attributes
6. Derived Attributes
7. Identifiers
Relationship Degrees
28
Relationship Cardinalities
29
Simple Attributes
⚫ An attribute that can not be subdivided into smaller
components is known as the simple attribute.
⚫It is also called atomic
attribute. For-Example:
A person can have only one
gender and one date of birth.
30
Composite Attribute
⚫ An attribute that can be divided into smaller components is
called
composite attribute.
For-Example:
⚫ Address is an example of composite attribute. It can be sub-
divide
into street, city, country.
⚫ Similarly, a phone number can be divided into Area code
and
Number.
31
Single-Valued Attribute
32
⚫ An attribute that may contain single value is called Single-
valued attribute.
For-Example:
⚫ Age of a person is a single- valued attribute.
⚫ Gender is also a single-valued attrbute.
Multi-Valued Attribute
⚫ An attribute that may contain two or more values is called
multi- valued attribute.
⚫ Multi-valued attribute is represented by double-line oval.
For-Example:
⚫ A person may have two or more college degrees.
⚫ Similarly, an employee may have many skills.
33
Stored
Attribute
34
⚫ An attribute that is stored in a database is called stored
attribute.
⚫ Most of the attributes are stored attributes.
⚫ These are stored and accessed from database.
Derived Attribute
35
⚫ An attribute that is not stored in a database but derived from
another value is called Derived attribute.
⚫ The other values can be stored in the database or obtained in
some other way.
⚫ A derived attribute is indicated by using an ellipse with a
dashed line.
Derived Attribute cont..
For example:
⚫ Roll no, name and Date of Birth of a student can be
stored in database. The age of the student can be derived
from Date of Birth.
36
Identifiers
37
⚫ Identifier is an attribute that identifies an entity instance
among other instances in entity class.
FOREXAMPLE
⚫ There may be many instances of STUDENT entity class. But
each
student is identified by his Roll No or Registration No.
⚫ Similarly an employee in EMPLOYEE entity class is identified
by his
Employee ID etc..
⚫ These attributes are known as Identifiers.
Identifiers cont…
38
Identifiers cont..
39
⚫ An Identifier can be unique or non-unique.
⚫ A unique identifier may identify only one entity instance.
⚫ A non-unique identifier may identify a set of instances.
For Example:
⚫ EmployeeID is a unique identifier. It identifies a single
employee. But Department is non-unique identifier. It
identifies all employees who work in a particular department.
Identifiers cont..
40
Simple Identifier
A identifier that consist of one attribute is called simple attribute
For example
The identifier of STUDENT entity type is Student_Id.
Composite Identifier
A identifier that consists of composite attribute is called
composite attribute.
For example
OrderID identifer may consist of OrderNo and Date.
41
Entitie
s
42
Entities
43
Different types of entities are represented in E-R
diagrams
⚫ Weak Entities/ Strong Entities
⚫ Associative Entities
Weak Entities
44
⚫ An entity that can exist only if another entity exists is known
as weak entity.
⚫ It means that weak entities depend upon the existence of
another
entity.
⚫ Suppose we want to store the data of a student after assigning
a class to him. It means that data can not be stored if CLASS
entity does not exist. In order to store the record of the
student, we first need to create an entity that represent a
class. Here, STUDENT is a weak entity because it depends
upon on CLASS entity.
Weak Entities Cont.…
45
⚫ The entity on which the weak entity depends is called
owner or identifying owner. A weak entity is represented
by doubled line square.
Strong Entities
46
⚫ An entity that can exist without depending upon the
existence of another entity is known as strong entity.
⚫ In previous, example, CLASS is a strong entity.
⚫ A strong entity is called parent, owner or dominant entity.
⚫ A weak entity is called child, dependent or subordinate
entity.
Example
⚫ In the above example, CHILD is a weak entity and PERSON is
its identifying owner. The relationship of these entities is
represented by double-lined diamond. It is called Identifying
Relationship.
47
Associative Entities
48
⚫ Associative entity is a type of entity that associates the
instances of one or many entity types with one another.
⚫ The attributes of associative represent the relationship
between the entity instances.
⚫ The following figure shows that a scholar gets an award on
his research. The entity AWARD has independent meaning to
the user.
49
Degree of
Relationship
50
Degree of Relationship
51
⚫ A relationship may consist of many entities. The number of
entities in a relationship is called degree of relationship.
⚫ The relationship of degree 2 are most common and are also
called binary relationship.
⚫ The types of relationships with respect
1. Unary Relationship
2. Binary Relationship
3. Ternary Relationship
Unary Relationship
52
⚫ Unary relationship is a type of relationship that is
established between the instances of same entity type.
This is known as recursive relationship.
The above relationship means that a person lives with
another person
PERSON Lives
with
Examples
53
The above relationship means that a teacher works
with another teacher.
TEACHER Works
with
Examples
54
Binary Relationship
55
⚫ Binary relationships exist between the instances of two
entity types. Different types of relationships are as follows:
1. One-to-One Relationship
2. One-to-Many Relationship
3. Many-to-One Relationship
One-to-One Relationship
56
⚫ This type of relationship is used when “for each instance
in first entity class, there is only one instance in the second
entity class and for each instance in second entity class, there
is only one instance in the first entity class”.
Exampl
esCHAIRMAN DEPARTMENT
Runs
COUNTRY PRESIDENT
has
The above relationship means one chairman runs only one department.
Similarly
one department is run by one chairman.
57
The above relationship means one country has one president.
Similarly
one president is for only one country.
Exampl
esMANAGER BRANCH
Manage
s
The above relationship means one manager manages one
branch of a
bank. Similarly one branch of a bank is managed by one
manager.
58
One-to-Many Relationship
59
⚫ This type of relationship is used when “for each instance
in first entity class, there can be many instances in the
second entity class and for each instance in second entity
class, there is only one instance in the first entity class”.
Exampl
es
The above relationship means one state can have many cities but one city
is
belonged to one state.
The above relationship means one college can have many departments but
one
department is part .
has
STATE CITY
has
COLLEGE DEPARTMENT
60
Exampl
es
The above relationship means one employer can employ many employees but
one
employee is employed by only one employer.
Employs
EMPLOYER EMPLOYEE
61
Many-to-Many Relationship
62
⚫ This type of relationship is used when “for each instance
in first entity class, there can be many instances in the
second entity class and for each instance in second entity
class, can be many instances in the first entity class”.
Exampl
es
The above relationship means that one student may study many courses and
one
course many be studied by many students
The above relationship means that one employee can learn many skills and
one
skills can be learned by many employees.
studies
STUDENT COURSE
learns
EMPLOYEE SKILLS
63
Exampl
es
The above relationship means that one reader may read many books and one
book
many be read by many readers.
reads
READER BOOKS
64
Ternary Relationship
⚫ Ternary relationship exists among the instances of three
entity types.
signs
CONSULTANT CLIENT
CONTARCT
The above relationship means that one or many consultants with one or many
clients
sign one or many contracts.
65
Ternary Relationship cont..
signs
ANAYLST PROGRAMMERS
PROJECTS
The above relationship means that one or many analysts with one or many
programmers works on one or many projects.
66
Cardinality
Constraints
67
Cardinality Constraints
⚫ The maximum number of relationships is called cardinality.
⚫ The cardinality constraint specifies the number of instances
of one
entity that can be associated with each instance of the other
entity.
⚫ There are three symbols used to show degree.
1
.
A circle means zero,
2. a line means one and
3. crow’s foot symbol
means many.
68
Cardinality Constraints
69
A circle
⚫ A circle indicates that relationship is optional. It means
that the minimum number of relationships between each
instance of the first entity and instances of related entity is
zero.
A stroke
⚫ A stroke indicates that the relationship is mandatory. It
means that minimum number of relationships between
each instance of first entity and instances of related entity is
one.
⚫ A stroke indicates that maximum number of relationships is
Cardinality Constraints
70
A crow’s foot
⚫ A crows-foot indicates that many relationships between
instances of
related entities may exist.
⚫ These symbols are as follows:
Mandatory One
71
Mandatory Many
Optional One
Optional Many
Minimum Cardinality
72
⚫ The minimum number of instances of one entity that
may be associated with each instance of another entity
is known as minimum cardinality.
⚫ If the minimum cardinality is zero, participant is optional.
⚫ If the minimum cardinality is 1, participant is mandatory.
Maximum Cardinality
73
⚫ The maximum number of instances of one entity that
may be associated with each instance of another entity
is known as maximum cardinality.
Example: One-to- Many
Relationship (Optional)
⚫ The following relationship between STUDENT and BOOK.
It depicts a
situation in a library where a student can borrow books from the
library.
⚫ The shape with STUDENT shows that minimum cardinality of
STUDENT
is zero and maximum is 1.
⚫ The shape with BOOK shows that there can be zero or many
instances of books associated with one student. The minimum
cardinality of BOOK is zero and maximum is many.
⚫ It means that one student can borrow zero or many books and one
book can
be borrowed by one or more student.
STUDENT BOOKS
74
Example: Many-to-
One
Relationship (Mandatory)
⚫ The following example shows a relationshipbetween EMPLOYEE
and
PROJECT. It depicts a situation in an organization where employees
work on
different places
⚫ The shape with EMPLOYEE shows the minimum cardinality is
zero and maximum is many.
⚫ The shape with PROJECT shows the minimum and maximum
cardinality
is 1.
⚫ There must be exactly one instance of project in the relationship. It
means that zero or many employees may be working on one
project. But employee must work on exactly one project.
EMPLOYEE PROJECT
75
Example: Many-to- Many
Relationship (mandatory)
⚫ The following example shows a relationship between
STUDENT and COURSE. It depicts a situation in an institution
the students can take different courses.
⚫ The minimum cardinality on both sides is zero. The maximum
cardinality on
both sides is many.
⚫ It means that one student can take many or no course to study.
Similarly, one
course can be taken by many students or no student.
STUDENT COURSES
76
Example: Many-to-
one Relationship
(Optional)
⚫ The following example shows a relationship between
PERSON and HOBBY. It depicts a situation in daily life where
a person may have no or one hobby.
⚫ The minimum cardinality of PERSON is zero and maximum is
many. The minimum cardinality of HOBBY is zero and
maximum is one.
⚫ It means that one person can have one or no hobby.
Similarly, one
hobby can be associated with many person or no person.
PERSON HOBBY
77
78
Subtype & Supertype Entities
79
⚫ An entity that contains some optional attributes or subtypes is
called a
subtype entity.
⚫ For example,
⚫ An entity CUSTOMER has the attributes CustomerID, Address and
Phone.
⚫ A customer can be an individual or an organization.
⚫ The following additional information is required to be stored
about the
customer depending on the type of the customer:
⚫ For Individual: NIC, Profession, Designation
⚫ For Organization: RegistrationID, ContactPerson, TaxID
Subtype & Supertype
Entities
80
⚫ One way to manage this situation is to allocate all above
attributes to the entity CUSTOMER. The CUSTOMER contains
the following attributes:
CustomerID
Address
Phone
NIC
Profession
Designation
RegistrationID
Contact Person
TaxID
Subtype & Supertype
Entities
81
⚫ If the customer is an individual, RegistrationID,
ContactPerson and TaxID are not used. If the customer is
an organization, NIC, Profession and Designation is not
used.
Subtype & Supertype
Entities
⚫ The second way to mange this situation is to use subtype as
follows:
Figure: Super Type and Sub Type Entities
⚫ The curve on the line indicates that it is a
subtype.
CUSTOMER
INDIVIDUAL ORGANIZATION
Super Type
Sub Type
82
Subtype & Supertype
Entities
⚫
83
CustomerID
Address
Phone
NIC
Profession
Designation
RegistrationID
ContactPerson
TaxID
CUSTOMER
contains
INDIVIDUAL
contains
ORGANIZATION
contains
Subtype & Supertype
Entities
84
⚫ This structure of super and subtypes are also called
generalization hierarchies because Customer is
generalization of both Individuals and Organization.
⚫ It is also known as IS-A relationship because Individual
is a
Customer and Organization is a Customer.
Generalization
85
⚫ Generalization is a process of identifying more general entity
type.
Fro Example:
⚫ HUMAN is a more general entity type than STUDENT or
LAWYER.
⚫ The entity type HUMAN contains attributes that are more
general than other two entity types. It may contain the
attributes like NAME, ADDRESS and AGE etc.
⚫ The entity type STUDDNT contains the attributes which are
specific
to students like ROLLNO, MARKS and GRADE etc.
Specialization
86
⚫ Specialization is a process of identifying more specific
entity type.
LAWYER are more specific entity types
than
⚫ For Example:
⚫ STUDENT
and
HUMAN.
Specialization
Address
Name
Email
Roll no
Salary
Emp ID
HUMAN
STUDENT EMPLOYEE
Class
87
Specialization
88
⚫ Inabove figure, HUMAN is super-type and STUDENT
and
EMPLOYEE are its two subtype.
⚫ The subtype also contain attributes of super-type along with
their
own additional attributes.
⚫ The subtypes are identified from one super-type with the
process of
specialization.

More Related Content

PPT
ER-Model-ER Diagram
PPTX
E-R Diagram and their models using datbase
PPT
3144-unit-1entityrmodel-171122051336.ppt
PPTX
Data model and entity relationship
PPT
ER Diagram introduction .ppt
PPT
ermodelN in database management system.ppt
PPTX
Presentation on Entity Relationship Diagram.pptx
PPT
ERD_01B=DBMS DATA BASE MANAGEMENT SYSTEM.ppt
ER-Model-ER Diagram
E-R Diagram and their models using datbase
3144-unit-1entityrmodel-171122051336.ppt
Data model and entity relationship
ER Diagram introduction .ppt
ermodelN in database management system.ppt
Presentation on Entity Relationship Diagram.pptx
ERD_01B=DBMS DATA BASE MANAGEMENT SYSTEM.ppt

Similar to Database week 5 lecture includes spexiafix (20)

ODP
ER Model in DBMS
PDF
Db lec 02_new
PPTX
DBMS_Data Model,Keys,Attributes,Relationship.pptx
PPTX
Data Models and Relational Database Design.pptx
PPTX
Introduction of Database Design and Development
PPTX
IT6701 Information Management Unit-I
PPTX
Data modeling
PPT
Database design
PPTX
PPTX
Database part3-
PPTX
Database Systems (3+1)_Entity Relationship Models (2).pptx
PPTX
Day 1 SQL.pptx
PPTX
SQL.pptx
PPTX
Entity Relationship Modelling
PPTX
E_R-Diagram (2).pptx
PPTX
Database management systems 3 - Data Modelling
PPTX
E-R diagram in Database
PPT
PPTX
ER-Diagram.pptx , ER diagram , entity reltaionship diagram , data base
ER Model in DBMS
Db lec 02_new
DBMS_Data Model,Keys,Attributes,Relationship.pptx
Data Models and Relational Database Design.pptx
Introduction of Database Design and Development
IT6701 Information Management Unit-I
Data modeling
Database design
Database part3-
Database Systems (3+1)_Entity Relationship Models (2).pptx
Day 1 SQL.pptx
SQL.pptx
Entity Relationship Modelling
E_R-Diagram (2).pptx
Database management systems 3 - Data Modelling
E-R diagram in Database
ER-Diagram.pptx , ER diagram , entity reltaionship diagram , data base
Ad

Recently uploaded (20)

PPTX
text mining_Natural Language Processing.pptx
PPTX
PSU research training.pptxPSU research training.pptx
PPTX
Bussiness Plan S Group of college 2020-23 Final
PPT
Technicalities in writing workshops indigenous language
PPTX
Transport System for Biology students in the 11th grade
PPTX
BDA_Basics of Big data Unit-1.pptx Big data
PPTX
Chapter_5_ network layer control plan v8.2.pptx
PDF
American Journal of Multidisciplinary Research and Review
PDF
toaz.info-grade-11-2nd-quarter-earth-and-life-science-pr_5360bfd5a497b75f7ae4...
PDF
NU-MEP-Standards معايير تصميم جامعية .pdf
PPTX
Evaluasi program Bhs Inggris th 2023-2024 dan prog th 2024-2025-1.pptx
PPTX
An Introduction to Lean Six Sigma for Bilginer
PPTX
cardiac failure and associated notes.pptx
PPT
Handout for Lean and Six Sigma application
PDF
Library Hi Tech, technology of the world
PPTX
ISO 9001-2015 quality management system presentation
PPTX
Understanding AI: Basics on Artificial Intelligence and Machine Learning
PPTX
REAL of PPT_P1_5019211081 (1).pdf_20250718_084609_0000.pptx
PDF
MISO Deep-NARX Forecasting for Energy and Electricity Demand/Price Data
PPTX
Machine Learning: An Introduction to Smart AI
text mining_Natural Language Processing.pptx
PSU research training.pptxPSU research training.pptx
Bussiness Plan S Group of college 2020-23 Final
Technicalities in writing workshops indigenous language
Transport System for Biology students in the 11th grade
BDA_Basics of Big data Unit-1.pptx Big data
Chapter_5_ network layer control plan v8.2.pptx
American Journal of Multidisciplinary Research and Review
toaz.info-grade-11-2nd-quarter-earth-and-life-science-pr_5360bfd5a497b75f7ae4...
NU-MEP-Standards معايير تصميم جامعية .pdf
Evaluasi program Bhs Inggris th 2023-2024 dan prog th 2024-2025-1.pptx
An Introduction to Lean Six Sigma for Bilginer
cardiac failure and associated notes.pptx
Handout for Lean and Six Sigma application
Library Hi Tech, technology of the world
ISO 9001-2015 quality management system presentation
Understanding AI: Basics on Artificial Intelligence and Machine Learning
REAL of PPT_P1_5019211081 (1).pdf_20250718_084609_0000.pptx
MISO Deep-NARX Forecasting for Energy and Electricity Demand/Price Data
Machine Learning: An Introduction to Smart AI
Ad

Database week 5 lecture includes spexiafix

  • 2. Data Models ⚫ A data model defines how a database logically structures and organizes data ⚫ Data Models are fundamental entities to introduce abstraction in a DBMS. ⚫ Data models define how data is connected to each other and how they are processed and stored inside the system. ⚫ The very first data model could be flat data-models, where all the data used are to be kept in the same plane. Earlier data models were not so scientific, hence they were prone to introduce lots of duplication and update anomalies.
  • 3. Entity-Relationship Model ⚫ Entity-Relationship (ER) Model is based on the notion of real- world entities and relationships among them. ⚫ While formulating real-world scenario into the database model, the ER Model creates entity set, relationship set, general attributes, and constraints. ⚫ ER Model is best used for the conceptual design of a database. ⚫ ER Model is based on:  Entities and their attributes.  Relationships among entities.
  • 4. ER Model Entity ⚫ An entity in an ER Model is a real-world entity that has independence existence. Attribute: ⚫An entity in an ER Model having properties called attributes. Domain ⚫ Every attribute is defined by its set of values called domain. ⚫ For example, in a school database, a student is considered as an entity.
  • 5. ER Model logical association among entities is called ⚫ Relationship The relationship. ⚫ Relationships are mapped with entities in variousways. Mapping cardinalities define the number of association between two entities. ⚫ Mapping cardinalities: ⚫ o one to one ⚫ o one to many ⚫ o many to one ⚫ o many to many
  • 6. Relational Model ⚫ The most popular data model in DBMS is the Relational Model. It is more scientific model than others. ⚫ This model is based on first-order predicate logic and defines a table as an n-ary relation.
  • 8. ER Model The main highlights of this model are: ⚫Data is stored in tables called relations. ⚫Relations can be normalized. ⚫In normalized relations, values saved are atomic values. ⚫Each row in a relation contains a unique value. ⚫Each column in a relationcontainsvaluesfrom a same domain.
  • 9. Entity Relationship Model 9 ⚫Entity Relationship is a logical representation of data in an organization. ⚫It views the entire system as a collection of entities related to another. ⚫It is used to describe the elements of a system and their relationships. ⚫It was introduced by Peter Chen in 1976.
  • 10. Advantages of E-R Model 10 Some important advantages of E-R model are as follows: 1. Conceptual Simplicity ER model represents the concept of a database along with its entities and a relationship in an easy way. It becomes easier to create and manage the complex database designs by using E-R model. 2. Visual Representation E-R model provides a visual representation of data and the relationships among data. It enables database designers, programmers and end users to understand database easily.
  • 11. Advantages of E-R Model 11 3. Effective Communication Tool The database designer can use E-R model to get different views of data as seen by programmers, managers and end users etc. E- R model works as an effective communication tool to integrate these views. 4. Integrated with relational database E-R model is well integrated with the relational database model. This integration makes relational database design a very structured process.
  • 12. Elements of ERD 12 Different elements of an E-R Model: ⚫ Entities ⚫ Attributes ⚫ Relationships
  • 13. Entities 13 ⚫ An entity is a person, place, thing or event for which data is collected and maintained. For Example: ⚫ A library system may contain data about different entities like BOOKS and MEMBER. ⚫ A college system may include entities like STUDENT, TEACHER and CLASS etc.
  • 14. Entities cont.… 14 Some examples of entities ⚫ Person: TEACHER, PLAYER, DOCTOR ⚫ Place: COUNTRY, CITY ⚫ Object: VEHICLE, TOY, FURNITURE ⚫ Event: PURCHASE, ADMISSION, REGISTRATION ⚫ Concept: ACCOUNT, PROGRAMMING An entity is represented by rectangle. The name of the entity is written inside the rectangle.
  • 15. Entities Cont.… 15 The entity is used in three different meanings that are as follows: ⚫ Entity Type ⚫ Entity Instance ⚫ Entity Set
  • 16. Entities Type 16 ⚫ A set of entities with the same attributes is called entity type. ⚫ All entities in an entity type share common characteristics. It is Also known as entity class. ⚫ For Example: ⚫ STUDENT entity class is a set of all students. ⚫ Similarly, BOOK entity type is a collection of all books etc.
  • 17. Entities Instance 17 ⚫ A member of an entity class is known as an Entity Instance. ⚫ Each entity instance of an entity type has its own value for each instance. For Example: ⚫ A student Ali of STUDENT entity type is an entity instance.
  • 18. Entity Set 18 ⚫ A set of all entities of a particular entity type in the database at a given point of time is called an Entity Set. For Example: ⚫ An entity set Student may consist of all students in the university. ⚫ Another entity set Teacher may consist of all teachers in the university etc... ⚫ The same name is usually used for both entity type and entity set. For example BOOKS refers to both a entity type and as well as the current set of all books in the database.
  • 19. Attribute s 19 ⚫ The characteristics of an entity are called attributes or properties. ⚫ For Example: Name, Address, Class and Email of a student are his attributes. ⚫ All instances of a particular entity class have same attributes. For Example, all students of STUDENT entity class have the attributes of Names, Address, Class and Email.
  • 20. Attribute Domain 20 ⚫ An attribute domain is a set of possible values for an attribute. All attributes have domain. The domain may consist of a range of values or some discrete values. For Example: ⚫ The domain for Grade Point Average (GPA) can be from 0 to 4. ⚫ Similarly, the domain for Gender attribute can be Male or Female.
  • 21. Attribute Domain cont.. 21 ⚫ The association of a domain with an attribute ensures the integrity of database. The domain is normally defined in form of data type and some additional constraints like range constraint. For Example: ⚫ If the data type of a field is integer, it can store only integer values.
  • 22. Relationships 22 ⚫ A relationship is a logical connection between different entities. ⚫ The entities that participate in a relationship is called participants. ⚫ The relationship may be between different entities or between an entity and itself. ⚫ A relationship is established on the basis of interaction among these entities. For Example: ⚫ A relationship exists between a STUDENT and TEACHER because
  • 23. Relationships cont… 23 ⚫ A relationship is called Total if all entities of that entity set may be participant in the relationship. ⚫ A relationship is called partial if some of the entities of that entity set may be participant in the relationship. ⚫ Suppose : A relationship SUPP_Part exists between Supplier and PART. ⚫ The relationship is total if every part is supplied by a supplier. The relationship is partial if certain parts are available without a supplier.
  • 24. 24
  • 25. E-R Diagram 25 ⚫ E-R diagram is a graphical Representation of E-R model using a set of standard symbols. Different symbol used in E-R diagram are as follows:
  • 26. 26
  • 27. Types of Attributes 27 Different types of attributes are represented in E-R diagram as follows: 1. Simple Attribute 2. Composite Attribute 3. Single-Valued Attribute 4. Multi-Valued Attribute 5. Stored Attributes 6. Derived Attributes 7. Identifiers
  • 30. Simple Attributes ⚫ An attribute that can not be subdivided into smaller components is known as the simple attribute. ⚫It is also called atomic attribute. For-Example: A person can have only one gender and one date of birth. 30
  • 31. Composite Attribute ⚫ An attribute that can be divided into smaller components is called composite attribute. For-Example: ⚫ Address is an example of composite attribute. It can be sub- divide into street, city, country. ⚫ Similarly, a phone number can be divided into Area code and Number. 31
  • 32. Single-Valued Attribute 32 ⚫ An attribute that may contain single value is called Single- valued attribute. For-Example: ⚫ Age of a person is a single- valued attribute. ⚫ Gender is also a single-valued attrbute.
  • 33. Multi-Valued Attribute ⚫ An attribute that may contain two or more values is called multi- valued attribute. ⚫ Multi-valued attribute is represented by double-line oval. For-Example: ⚫ A person may have two or more college degrees. ⚫ Similarly, an employee may have many skills. 33
  • 34. Stored Attribute 34 ⚫ An attribute that is stored in a database is called stored attribute. ⚫ Most of the attributes are stored attributes. ⚫ These are stored and accessed from database.
  • 35. Derived Attribute 35 ⚫ An attribute that is not stored in a database but derived from another value is called Derived attribute. ⚫ The other values can be stored in the database or obtained in some other way. ⚫ A derived attribute is indicated by using an ellipse with a dashed line.
  • 36. Derived Attribute cont.. For example: ⚫ Roll no, name and Date of Birth of a student can be stored in database. The age of the student can be derived from Date of Birth. 36
  • 37. Identifiers 37 ⚫ Identifier is an attribute that identifies an entity instance among other instances in entity class. FOREXAMPLE ⚫ There may be many instances of STUDENT entity class. But each student is identified by his Roll No or Registration No. ⚫ Similarly an employee in EMPLOYEE entity class is identified by his Employee ID etc.. ⚫ These attributes are known as Identifiers.
  • 39. Identifiers cont.. 39 ⚫ An Identifier can be unique or non-unique. ⚫ A unique identifier may identify only one entity instance. ⚫ A non-unique identifier may identify a set of instances. For Example: ⚫ EmployeeID is a unique identifier. It identifies a single employee. But Department is non-unique identifier. It identifies all employees who work in a particular department.
  • 40. Identifiers cont.. 40 Simple Identifier A identifier that consist of one attribute is called simple attribute For example The identifier of STUDENT entity type is Student_Id. Composite Identifier A identifier that consists of composite attribute is called composite attribute. For example OrderID identifer may consist of OrderNo and Date.
  • 41. 41
  • 43. Entities 43 Different types of entities are represented in E-R diagrams ⚫ Weak Entities/ Strong Entities ⚫ Associative Entities
  • 44. Weak Entities 44 ⚫ An entity that can exist only if another entity exists is known as weak entity. ⚫ It means that weak entities depend upon the existence of another entity. ⚫ Suppose we want to store the data of a student after assigning a class to him. It means that data can not be stored if CLASS entity does not exist. In order to store the record of the student, we first need to create an entity that represent a class. Here, STUDENT is a weak entity because it depends upon on CLASS entity.
  • 45. Weak Entities Cont.… 45 ⚫ The entity on which the weak entity depends is called owner or identifying owner. A weak entity is represented by doubled line square.
  • 46. Strong Entities 46 ⚫ An entity that can exist without depending upon the existence of another entity is known as strong entity. ⚫ In previous, example, CLASS is a strong entity. ⚫ A strong entity is called parent, owner or dominant entity. ⚫ A weak entity is called child, dependent or subordinate entity.
  • 47. Example ⚫ In the above example, CHILD is a weak entity and PERSON is its identifying owner. The relationship of these entities is represented by double-lined diamond. It is called Identifying Relationship. 47
  • 48. Associative Entities 48 ⚫ Associative entity is a type of entity that associates the instances of one or many entity types with one another. ⚫ The attributes of associative represent the relationship between the entity instances. ⚫ The following figure shows that a scholar gets an award on his research. The entity AWARD has independent meaning to the user.
  • 49. 49
  • 51. Degree of Relationship 51 ⚫ A relationship may consist of many entities. The number of entities in a relationship is called degree of relationship. ⚫ The relationship of degree 2 are most common and are also called binary relationship. ⚫ The types of relationships with respect 1. Unary Relationship 2. Binary Relationship 3. Ternary Relationship
  • 52. Unary Relationship 52 ⚫ Unary relationship is a type of relationship that is established between the instances of same entity type. This is known as recursive relationship.
  • 53. The above relationship means that a person lives with another person PERSON Lives with Examples 53
  • 54. The above relationship means that a teacher works with another teacher. TEACHER Works with Examples 54
  • 55. Binary Relationship 55 ⚫ Binary relationships exist between the instances of two entity types. Different types of relationships are as follows: 1. One-to-One Relationship 2. One-to-Many Relationship 3. Many-to-One Relationship
  • 56. One-to-One Relationship 56 ⚫ This type of relationship is used when “for each instance in first entity class, there is only one instance in the second entity class and for each instance in second entity class, there is only one instance in the first entity class”.
  • 57. Exampl esCHAIRMAN DEPARTMENT Runs COUNTRY PRESIDENT has The above relationship means one chairman runs only one department. Similarly one department is run by one chairman. 57 The above relationship means one country has one president. Similarly one president is for only one country.
  • 58. Exampl esMANAGER BRANCH Manage s The above relationship means one manager manages one branch of a bank. Similarly one branch of a bank is managed by one manager. 58
  • 59. One-to-Many Relationship 59 ⚫ This type of relationship is used when “for each instance in first entity class, there can be many instances in the second entity class and for each instance in second entity class, there is only one instance in the first entity class”.
  • 60. Exampl es The above relationship means one state can have many cities but one city is belonged to one state. The above relationship means one college can have many departments but one department is part . has STATE CITY has COLLEGE DEPARTMENT 60
  • 61. Exampl es The above relationship means one employer can employ many employees but one employee is employed by only one employer. Employs EMPLOYER EMPLOYEE 61
  • 62. Many-to-Many Relationship 62 ⚫ This type of relationship is used when “for each instance in first entity class, there can be many instances in the second entity class and for each instance in second entity class, can be many instances in the first entity class”.
  • 63. Exampl es The above relationship means that one student may study many courses and one course many be studied by many students The above relationship means that one employee can learn many skills and one skills can be learned by many employees. studies STUDENT COURSE learns EMPLOYEE SKILLS 63
  • 64. Exampl es The above relationship means that one reader may read many books and one book many be read by many readers. reads READER BOOKS 64
  • 65. Ternary Relationship ⚫ Ternary relationship exists among the instances of three entity types. signs CONSULTANT CLIENT CONTARCT The above relationship means that one or many consultants with one or many clients sign one or many contracts. 65
  • 66. Ternary Relationship cont.. signs ANAYLST PROGRAMMERS PROJECTS The above relationship means that one or many analysts with one or many programmers works on one or many projects. 66
  • 68. Cardinality Constraints ⚫ The maximum number of relationships is called cardinality. ⚫ The cardinality constraint specifies the number of instances of one entity that can be associated with each instance of the other entity. ⚫ There are three symbols used to show degree. 1 . A circle means zero, 2. a line means one and 3. crow’s foot symbol means many. 68
  • 69. Cardinality Constraints 69 A circle ⚫ A circle indicates that relationship is optional. It means that the minimum number of relationships between each instance of the first entity and instances of related entity is zero. A stroke ⚫ A stroke indicates that the relationship is mandatory. It means that minimum number of relationships between each instance of first entity and instances of related entity is one. ⚫ A stroke indicates that maximum number of relationships is
  • 70. Cardinality Constraints 70 A crow’s foot ⚫ A crows-foot indicates that many relationships between instances of related entities may exist. ⚫ These symbols are as follows:
  • 72. Minimum Cardinality 72 ⚫ The minimum number of instances of one entity that may be associated with each instance of another entity is known as minimum cardinality. ⚫ If the minimum cardinality is zero, participant is optional. ⚫ If the minimum cardinality is 1, participant is mandatory.
  • 73. Maximum Cardinality 73 ⚫ The maximum number of instances of one entity that may be associated with each instance of another entity is known as maximum cardinality.
  • 74. Example: One-to- Many Relationship (Optional) ⚫ The following relationship between STUDENT and BOOK. It depicts a situation in a library where a student can borrow books from the library. ⚫ The shape with STUDENT shows that minimum cardinality of STUDENT is zero and maximum is 1. ⚫ The shape with BOOK shows that there can be zero or many instances of books associated with one student. The minimum cardinality of BOOK is zero and maximum is many. ⚫ It means that one student can borrow zero or many books and one book can be borrowed by one or more student. STUDENT BOOKS 74
  • 75. Example: Many-to- One Relationship (Mandatory) ⚫ The following example shows a relationshipbetween EMPLOYEE and PROJECT. It depicts a situation in an organization where employees work on different places ⚫ The shape with EMPLOYEE shows the minimum cardinality is zero and maximum is many. ⚫ The shape with PROJECT shows the minimum and maximum cardinality is 1. ⚫ There must be exactly one instance of project in the relationship. It means that zero or many employees may be working on one project. But employee must work on exactly one project. EMPLOYEE PROJECT 75
  • 76. Example: Many-to- Many Relationship (mandatory) ⚫ The following example shows a relationship between STUDENT and COURSE. It depicts a situation in an institution the students can take different courses. ⚫ The minimum cardinality on both sides is zero. The maximum cardinality on both sides is many. ⚫ It means that one student can take many or no course to study. Similarly, one course can be taken by many students or no student. STUDENT COURSES 76
  • 77. Example: Many-to- one Relationship (Optional) ⚫ The following example shows a relationship between PERSON and HOBBY. It depicts a situation in daily life where a person may have no or one hobby. ⚫ The minimum cardinality of PERSON is zero and maximum is many. The minimum cardinality of HOBBY is zero and maximum is one. ⚫ It means that one person can have one or no hobby. Similarly, one hobby can be associated with many person or no person. PERSON HOBBY 77
  • 78. 78
  • 79. Subtype & Supertype Entities 79 ⚫ An entity that contains some optional attributes or subtypes is called a subtype entity. ⚫ For example, ⚫ An entity CUSTOMER has the attributes CustomerID, Address and Phone. ⚫ A customer can be an individual or an organization. ⚫ The following additional information is required to be stored about the customer depending on the type of the customer: ⚫ For Individual: NIC, Profession, Designation ⚫ For Organization: RegistrationID, ContactPerson, TaxID
  • 80. Subtype & Supertype Entities 80 ⚫ One way to manage this situation is to allocate all above attributes to the entity CUSTOMER. The CUSTOMER contains the following attributes: CustomerID Address Phone NIC Profession Designation RegistrationID Contact Person TaxID
  • 81. Subtype & Supertype Entities 81 ⚫ If the customer is an individual, RegistrationID, ContactPerson and TaxID are not used. If the customer is an organization, NIC, Profession and Designation is not used.
  • 82. Subtype & Supertype Entities ⚫ The second way to mange this situation is to use subtype as follows: Figure: Super Type and Sub Type Entities ⚫ The curve on the line indicates that it is a subtype. CUSTOMER INDIVIDUAL ORGANIZATION Super Type Sub Type 82
  • 84. Subtype & Supertype Entities 84 ⚫ This structure of super and subtypes are also called generalization hierarchies because Customer is generalization of both Individuals and Organization. ⚫ It is also known as IS-A relationship because Individual is a Customer and Organization is a Customer.
  • 85. Generalization 85 ⚫ Generalization is a process of identifying more general entity type. Fro Example: ⚫ HUMAN is a more general entity type than STUDENT or LAWYER. ⚫ The entity type HUMAN contains attributes that are more general than other two entity types. It may contain the attributes like NAME, ADDRESS and AGE etc. ⚫ The entity type STUDDNT contains the attributes which are specific to students like ROLLNO, MARKS and GRADE etc.
  • 86. Specialization 86 ⚫ Specialization is a process of identifying more specific entity type. LAWYER are more specific entity types than ⚫ For Example: ⚫ STUDENT and HUMAN.
  • 88. Specialization 88 ⚫ Inabove figure, HUMAN is super-type and STUDENT and EMPLOYEE are its two subtype. ⚫ The subtype also contain attributes of super-type along with their own additional attributes. ⚫ The subtypes are identified from one super-type with the process of specialization.

Editor's Notes

  • #34: In a DBMS, stored attributes are the data that remain constant and fixed for an entity instance. These values help in deriving the derived attributes. For example: consider a customer entity in a bank. The customer's name, age, and address would be stored attributes. The customer's account balance (a derived attribute) could be calculated based on the transactions (another stored attribute) associated with the customer.