Entity-Relationship Model in Databases

 
E
n
t
i
t
y
-
R
e
l
a
t
i
o
n
s
h
i
p
(
E
/
R
)
 
M
o
d
e
l
 
Ali Akbar Mohammadi
 
E
n
t
i
t
y
-
R
e
l
a
t
i
o
n
s
h
i
p
 
(
E
/
R
)
 
M
o
d
e
l
 
Widely used conceptual level data model
Proposed by Peter P Chen in 1970s
Data model to describe the database system at the requirements
collection stage
High level description.
Easy to understand for the enterprise managers.
Rigorous enough to be used for system building.
Concepts available in the model
Entities and attributes of entities.
Relationships between entities.
Diagrammatic notation.
 
Ali Akbar Mohammadi
 
2
 
E
n
t
i
t
i
e
s
 
Entity
: A thing (animate or inanimate) of independent physical or
conceptual existence and 
distinguishable
.
For example in the University database context, an individual 
student
,
faculty member
, a 
class room, 
a 
course 
are entities.
 
Ali Akbar Mohammadi
 
3
 
E
n
t
i
t
y
 
S
e
t
 
o
r
 
E
n
t
i
t
y
 
T
y
p
e
 
Collection of entities all having the same properties.
Student 
entity set –collection of all 
student 
entities.
Course 
entity set –collection of all 
course 
entities.
 
Ali Akbar Mohammadi
 
4
 
A
t
t
r
i
b
u
t
e
s
 
Each entity is described by a set of attributes/properties.
student 
entity
StudName
–name of the student.
RollNumber
–the roll number of the student.
Sex
–the gender of the student etc.
All entities in an Entity set/type have the same set of attributes.
Chosen set of attributes –amount of detail in modeling.
 
Ali Akbar Mohammadi
 
5
 
T
y
p
e
s
 
o
f
 
A
t
t
r
i
b
u
t
e
s
 
(
1
/
2
)
 
Simple Attributes
Having atomic or indivisible values.
example: Dept–a string
PhoneNumber–an eight digit number
Composite Attributes
Having several components in the value.
example: Qualification with components
(DegreeName, Year, UniversityName)
Derived Attributes
Attribute value is dependent on some other attribute.
example:Agedepends on DateOfBirth.
So age is a derived attribute.
 
Ali Akbar Mohammadi
 
6
 
T
y
p
e
s
 
o
f
 
A
t
t
r
i
b
u
t
e
s
 
(
2
/
2
)
 
Single-valued
having only one value rather than a set of values.
for instance, PlaceOfBirth–single string value.
Multi-valued
having a set of values rather than a single value.
for instance, CoursesEnrolled attribute for studentEmailAddress attribute for
studentPreviousDegree attribute for student.
Attributes can be:
simple single-valued, simple multi-valued, composite single-valued or
composite multi-valued.
 
Ali Akbar Mohammadi
 
7
 
D
i
a
g
r
a
m
m
a
t
i
c
 
N
o
t
a
t
i
o
n
 
f
o
r
 
E
n
t
i
t
i
e
s
 
entity -rectangle
attribute -ellipse connected to rectangle
multi-valued attribute -double ellipse
composite attribute -ellipse connected to ellipse
derived attribute-dashed ellipse
 
Ali Akbar Mohammadi
 
8
 
D
i
a
g
r
a
m
m
a
t
i
c
 
N
o
t
a
t
i
o
n
 
f
o
r
 
E
n
t
i
t
i
e
s
 
Ali Akbar Mohammadi
 
9
 
D
o
m
a
i
n
s
 
o
f
 
A
t
t
r
i
b
u
t
e
s
 
Each attribute takes values from a set called its domain
For instance, studentAge–{17,18, …, 55}
  
HomeAddress–character strings of length 35
Domain of composite attributes –
  
cross product of domains of component attributes
Domain of multi-valued attributes –
  
set of subsets of values from the basic domain
 
Ali Akbar Mohammadi
 
10
 
E
n
t
i
t
y
 
S
e
t
s
 
a
n
d
 
K
e
y
 
A
t
t
r
i
b
u
t
e
s
 
Key–an attribute or a collection of attributes whose value(s) uniquely
identify an entity in the entity set.
For instance,
RollNumber-Key for Student entity set
EmpID-Key for Faculty entity set
HostelName, RoomNo-Key for Student entity set(assuming that each student gets to
stay in a single room)
A key for an entity set may have more than one attribute.
An entity set may have more than one key.
Keys can be determined only from the meaning of the attributes in the
entity type.
Determined by the designers
 
Ali Akbar Mohammadi
 
11
 
R
e
l
a
t
i
o
n
s
h
i
p
s
 
When two or more entities are associated with each other, we have
an instance of a 
Relationship
.
E.g.: 
student 
Ali 
enrolls 
in Discrete Mathematics 
course
Relationship 
enrolls 
has 
Student 
and 
Course 
as the 
participating 
entity
sets.
Formally, 
enrolls 
Student 
×
Course
(s,c) 
enrolls 
 Student ‘s’ has enrolled in Course ‘c’
Tuples in 
enrolls
–relationship instances
Enrolls 
is called a relationship Type/Set.
 
Ali Akbar Mohammadi
 
12
 
D
e
g
r
e
e
 
o
f
 
a
 
R
e
l
a
t
i
o
n
s
h
i
p
 
Degree: the number of participating entities.
Degree 2: binary
Degree 3: ternary
Degree n: n-ary
Binary relationships are very common and widely used
 
Ali Akbar Mohammadi
 
13
 
D
i
a
g
r
a
m
m
a
t
i
c
 
N
o
t
a
t
i
o
n
 
f
o
r
 
R
e
l
a
t
i
o
n
s
h
i
p
s
 
Relationship –diamond shaped box
Rectangle of each participating entity is connected by a line to this diamond.
Name of the relationship is written in the box.
 
Ali Akbar Mohammadi
 
14
 
B
i
n
a
r
y
 
R
e
l
a
t
i
o
n
s
h
i
p
s
 
a
n
d
 
C
a
r
d
i
n
a
l
i
t
y
 
R
a
t
i
o
 
 
 
The number of entities from 
E
2 
that an entity from 
E
1 
can possibly be
associated thru 
R
(and vice-versa) determines the 
cardinality ratio 
of
R.
Four possibilities are usually specified:
one-to-one (1:1)
one-to-many (1:N)
many-to-one (N:1)
many-to-many (M:N)
 
Ali Akbar Mohammadi
 
15
 
C
a
r
d
i
n
a
l
i
t
y
 
R
a
t
i
o
s
 
One-to-one:
  
An 
E
1 
entity may be associated with at most
    
one 
E
2
 
entity and similarly an 
E
2 
entity may be
    
associated with at most one 
E
1
 
entity.
One-to-many:
  
An 
E
1
 
entity may be associated with many
    
E
2
 
entities whereas an 
E
2
 
entity may be
    
associated with at most one 
E
1
 entity.
Many-to-one: 
  
( similar to above)
Many-to-many:
  
Many 
E
1 
entities may be associated with a
    
single 
E
2
 
entity and a single 
E
1
 
entity may be
    
associated with many 
E
2
 
entities.
 
Ali Akbar Mohammadi
 
16
 
C
a
r
d
i
n
a
l
i
t
y
 
R
a
t
i
o
 
e
x
a
m
p
l
e
 
(
o
n
e
-
t
o
-
o
n
e
)
 
Ali Akbar Mohammadi
 
17
 
C
a
r
d
i
n
a
l
i
t
y
 
R
a
t
i
o
 
e
x
a
m
p
l
e
 
(
m
a
n
y
-
t
o
-
o
n
e
/
o
n
e
-
t
o
-
m
a
n
y
)
 
Ali Akbar Mohammadi
 
18
 
C
a
r
d
i
n
a
l
i
t
y
 
R
a
t
i
o
 
e
x
a
m
p
l
e
 
(
m
a
n
y
-
t
o
-
m
a
n
y
)
 
Ali Akbar Mohammadi
 
19
 
P
a
r
t
i
c
i
p
a
t
i
o
n
 
C
o
n
s
t
r
a
i
n
t
s
 
An entity set may participate in a relation either 
totally 
or 
partially
.
Total participation
: Every entity in the set is involved in some
  
association (or tuple) of the relationship.
Partial participation
: Not all entities in the set are involved in
  
association (or tuples) of the relationship.
Notation:
 
Ali Akbar Mohammadi
 
20
 
E
x
a
m
p
l
e
 
o
f
 
t
o
t
a
l
/
p
a
r
t
i
a
l
 
P
a
r
t
i
c
i
p
a
t
i
o
n
 
Ali Akbar Mohammadi
 
21
Slide Note
Embed
Share

The Entity-Relationship Model (E/R Model) is a widely used conceptual data model proposed by Peter P. Chen. It provides a high-level description of the database system during the requirements collection stage. Entities represent things of independent existence, each described by a set of attributes. Attributes can be simple, composite, or derived, and can be single-valued or multi-valued. This model is essential in database design and is easy to understand for managers while being rigorous enough for system building.

  • Entity-Relationship Model
  • E/R Model
  • Database Design
  • Data Modeling
  • Peter P. Chen

Uploaded on Oct 09, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Entity Entity- -Relationship Relationship (E/R) Model (E/R) Model Ali Akbar Mohammadi

  2. Entity Entity- -Relationship (E/R) Model Relationship (E/R) Model Widely used conceptual level data model Proposed by Peter P Chen in 1970s Data model to describe the database system at the requirements collection stage High level description. Easy to understand for the enterprise managers. Rigorous enough to be used for system building. Concepts available in the model Entities and attributes of entities. Relationships between entities. Diagrammatic notation. Ali Akbar Mohammadi 2

  3. Entities Entities Entity: A thing (animate or inanimate) of independent physical or conceptual existence and distinguishable. For example in the University database context, an individual student, faculty member, a class room, a course are entities. Ali Akbar Mohammadi 3

  4. Entity Set or Entity Type Entity Set or Entity Type Collection of entities all having the same properties. Student entity set collection of all student entities. Course entity set collection of all course entities. Ali Akbar Mohammadi 4

  5. Attributes Attributes Each entity is described by a set of attributes/properties. student entity StudName name of the student. RollNumber the roll number of the student. Sex the gender of the student etc. All entities in an Entity set/type have the same set of attributes. Chosen set of attributes amount of detail in modeling. Ali Akbar Mohammadi 5

  6. Types of Attributes (1/2) Types of Attributes (1/2) Simple Attributes Having atomic or indivisible values. example: Dept a string PhoneNumber an eight digit number Composite Attributes Having several components in the value. example: Qualification with components (DegreeName, Year, UniversityName) Derived Attributes Attribute value is dependent on some other attribute. example:Agedepends on DateOfBirth. So age is a derived attribute. Ali Akbar Mohammadi 6

  7. Types of Attributes (2/2) Types of Attributes (2/2) Single-valued having only one value rather than a set of values. for instance, PlaceOfBirth single string value. Multi-valued having a set of values rather than a single value. for instance, CoursesEnrolled attribute for studentEmailAddress attribute for studentPreviousDegree attribute for student. Attributes can be: simple single-valued, simple multi-valued, composite single-valued or composite multi-valued. Ali Akbar Mohammadi 7

  8. Diagrammatic Notation for Entities Diagrammatic Notation for Entities entity -rectangle attribute -ellipse connected to rectangle multi-valued attribute -double ellipse composite attribute -ellipse connected to ellipse derived attribute-dashed ellipse Ali Akbar Mohammadi 8

  9. Diagrammatic Notation for Entities Diagrammatic Notation for Entities Ali Akbar Mohammadi 9

  10. Domains of Attributes Domains of Attributes Each attribute takes values from a set called its domain For instance, studentAge {17,18, , 55} HomeAddress character strings of length 35 Domain of composite attributes cross product of domains of component attributes Domain of multi-valued attributes set of subsets of values from the basic domain Ali Akbar Mohammadi 10

  11. Entity Sets and Key Attributes Entity Sets and Key Attributes Key an attribute or a collection of attributes whose value(s) uniquely identify an entity in the entity set. For instance, RollNumber-Key for Student entity set EmpID-Key for Faculty entity set HostelName, RoomNo-Key for Student entity set(assuming that each student gets to stay in a single room) A key for an entity set may have more than one attribute. An entity set may have more than one key. Keys can be determined only from the meaning of the attributes in the entity type. Determined by the designers Ali Akbar Mohammadi 11

  12. Relationships Relationships When two or more entities are associated with each other, we have an instance of a Relationship. E.g.: student Ali enrolls in Discrete Mathematics course Relationship enrolls has Student and Course as the participating entity sets. Formally, enrolls Student Course (s,c) enrolls Student s has enrolled in Course c Tuples in enrolls relationship instances Enrolls is called a relationship Type/Set. Ali Akbar Mohammadi 12

  13. Degree of a Relationship Degree of a Relationship Degree: the number of participating entities. Degree 2: binary Degree 3: ternary Degree n: n-ary Binary relationships are very common and widely used Ali Akbar Mohammadi 13

  14. Diagrammatic Notation for Relationships Diagrammatic Notation for Relationships Relationship diamond shaped box Rectangle of each participating entity is connected by a line to this diamond. Name of the relationship is written in the box. Ali Akbar Mohammadi 14

  15. Binary Relationships and Cardinality Ratio Binary Relationships and Cardinality Ratio The number of entities from E2 that an entity from E1 can possibly be associated thru R(and vice-versa) determines the cardinality ratio of R. Four possibilities are usually specified: one-to-one (1:1) one-to-many (1:N) many-to-one (N:1) many-to-many (M:N) Ali Akbar Mohammadi 15

  16. Cardinality Ratios Cardinality Ratios One-to-one: One-to-many: Many-to-one: Many-to-many: An E1 entity may be associated with at most one E2entity and similarly an E2 entity may be associated with at most one E1entity. An E1entity may be associated with many E2entities whereas an E2entity may be associated with at most one E1 entity. ( similar to above) Many E1 entities may be associated with a single E2entity and a single E1entity may be associated with many E2entities. Ali Akbar Mohammadi 16

  17. Cardinality Ratio Cardinality Ratio example (one example (one- -to to- -one) one) Ali Akbar Mohammadi 17

  18. Cardinality Ratio Cardinality Ratio example (many to to- -many) many) example (many- -to to- -one/one one/one- - Ali Akbar Mohammadi 18

  19. Cardinality Ratio Cardinality Ratio example (many example (many- -to to- -many) many) Ali Akbar Mohammadi 19

  20. Participation Constraints Participation Constraints An entity set may participate in a relation either totally or partially. Total participation: Every entity in the set is involved in some association (or tuple) of the relationship. Partial participation: Not all entities in the set are involved in association (or tuples) of the relationship. Notation: Ali Akbar Mohammadi 20

  21. Example of total/partial Participation Example of total/partial Participation Ali Akbar Mohammadi 21

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#