0% found this document useful (0 votes)
3 views

Entity Relationship model

The document provides an overview of the Entity-Relationship (ER) model, which was proposed by Peter Chen in 1971 as a conceptual modeling approach for databases. It covers key concepts such as entity sets, relationship sets, attributes, and mapping cardinalities, along with the use of ER diagrams to visually represent the structure of a database. The document also explains the significance of keys, weak entities, and various types of relationships in the context of database design.

Uploaded by

Sushma Borkar
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Entity Relationship model

The document provides an overview of the Entity-Relationship (ER) model, which was proposed by Peter Chen in 1971 as a conceptual modeling approach for databases. It covers key concepts such as entity sets, relationship sets, attributes, and mapping cardinalities, along with the use of ER diagrams to visually represent the structure of a database. The document also explains the significance of keys, weak entities, and various types of relationships in the context of database design.

Uploaded by

Sushma Borkar
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 93

ENTITY-RELATIONSHIP MODEL

1
1.2: Entity-Relationship Model

• Entity sets
• Relationship sets
• Attributes
• Constraints-- Mapping Cardinalities, Participation constraints
• Keys
• Entity-relationship diagrams: Basic Structure, Mapping
Cardinality, Complex Attributes, Roles, Non binary Relationship
Sets
• Weak Entity Sets.

2
The Entity-Relationship Model
• Peter Chen proposed ER Diagram in 1971 to create a uniform
convention that can be used for relational databases and networks. He
aimed to use an ER model as a conceptual modeling approach.

• Entity relationship (ER) models are based on the real-world entities


and their relationships. It is easy for the developers to understand the
system by simply looking at the ER diagram.

• ER models are normally represented by ER-diagrams.

• An ER model is a design or blueprint of a database that can later be


implemented as a database. This model is used to define the data
elements and relationship for a specified system.

• The E-R data model employs three basic concepts: entity sets,
relationship sets, and attributes. 3
Why use ER Diagrams?

• Helps you to define terms related to entity relationship modeling


• Provide a preview of how all your tables should connect, what fields are
going to be on each table
• Helps to describe entities, attributes, relationships
• ER diagrams are translatable into relational tables which allows you to
build databases quickly
• ER diagrams can be used by database designers as a blueprint for
implementing data in specific software applications
• The database designer gains a better understanding of the information
to be contained in the database with the help of ERP diagram
• ERD Diagram allows you to communicate with the logical structure of
the database to users

4
Facts about ER Diagram Model

• ER model allows you to draw Database Design


• It is an easy to use graphical tool for modeling data
• Widely used in Database Design
• It is a GUI representation of the logical structure of a Database
• It helps you to identifies the entities which exist in a system and the
relationships between those entities

5
• ER diagram basically having three components:

• Entities − It is a real-world thing which can be a person, place, or


even a concept. For Example: Department, Admin, Courses, Teachers,
Students, Building, etc are some of the entities of a School
Management System.
• Attributes − An entity which contains a real-world property called an
attribute. For Example: The entity employee has the property like
employee id, salary, age, etc.
• Relationship − Relationship tells how two attributes are related. For
Example: Employee works for a department.

6
7
Entity Sets
• Entity set:

• An entity set is a group of similar kind of entities. It may contain entities


with attribute sharing similar values.
• Entities are represented by their properties, which also called attributes.
• All attributes have their separate values.
• For example, a student entity may have a name, age, class, as attributes.
• In the ER diagram, an entity can be represented as rectangles.
• Consider an organization as an example- manager, product, employee,
department etc. can be taken as an entity.

8
Entity Sets

9
Relationship Sets
• A relationship is an association among two or more entities.
• When an Entity is related to another Entity, they are said to have a
relationship. For example, A Class Entity is related to Student entity,
becasue students study in classes, hence this is a relationship.
• For example, an employee works_at a department, a
student enrolls in a course. Here, Works_at and Enrolls are called
relationships.

• A set of relationships of similar type is called a relationship set.


10
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, one 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. n-ary Relationship –
When there are n entities set participating in a relation, the relationship is
called as n-ary relationship. 11
Relationship Sets

12
Relationship Sets
• A relationship may also have attributes called descriptive
attributes.

• Consider a relationship set advisor with entity sets instructor and


student.

• We could associate the attribute date with that relationship to


specify the date when an instructor became the advisor of a
student.

• The advisor relationship among the entities corresponding to


instructor Katz and student Shankar has the value “10 June 2007”
for attribute date, which means that Katz became Shankar’s advisor
on 10 June 2007.
13
Relationship Sets
• Figure 7.3 shows the relationship set advisor with a descriptive
attribute date.
• Please note that Katz advises two students with two different
advising dates.

14
Attributes
• An attribute describes the property of an entity. An attribute is
represented as Oval in an ER diagram.
• If a Student is an Entity, then student's roll no., student's name,
student's age, student's gender etc will be its attributes.

15
• There are four types of attributes:
1. Simple attribute:
The attributes with values that are atomic and cannot be
broken down further are simple attributes. For example, student's age, a
student's phone number is an atomic value of 10 digits.

2. Composite attribute:
A composite attribute is made up of more than one simple
attribute. For example, student's address will contain, house
no., street name, pincode etc.

16
3. Multivalued attribute:
Multivalued attributes can have more than one values. For example, a
student can have more than one mobile number, email address, etc.
In ER diagram, multivalued attribute is represented by double oval.

4. Derived attribute:
An attribute which can be derived from other attributes of the entity
type is known as derived attribute. e.g.; Age (can be derived from DOB). In ER
diagram, derived attribute is represented by dashed oval.

17
18
E-R Diagram Symbol

19
Weak Entities
• Strong Entity
• The strong entity has a primary key. Weak entities are dependent on
strong entity. Its existence is not dependent on any other entity.
• Strong Entity is represented by a single rectangle
• Weak Entity
• The weak entity in DBMS do not have a primary key and are
dependent on the parent entity. It mainly depends on other entities.
• It can be identified uniquely by considering the primary key of another
entity.
• Weak Entity is represented by double rectangle

20
• In the below ER Diagram, ‘Payment’ is the weak entity. ‘Loan Payment’ is
the identifying relationship and ‘Payment Number’ is the partial key.
Primary Key of the Loan along with the partial key would be used to
identify the records.

• Example-2:
The existence of rooms is entirely dependent on the existence of a hotel. So
room can be seen as the weak entity of the hotel.
• Example-3:
The bank account of a particular bank has no existence if the bank doesn’t
exist anymore. 21
• A loan entity can not be created for a customer if the customer doesn’t
exist

22
Mapping Cardinalities

23
Mapping cardinality
• It tells the number of entities to with another entity can be associated
through a 'relationship set' . Mapping cardinality uses binary
relationship sets.
• Different types of cardinal relationships are:
– One-to-One Relationships
– One-to-Many Relationships
– May to One Relationships
– Many-to-Many Relationships

24
1. One to One Relationship
•When a single instance of an entity is associated with a single instance
of another entity then it is called one to one relationship.
•For example, a person has only one passport and a passport is given to
one person.

25
One to Many Relationship
•When a single instance of an entity is associated with more than one
instances of another entity then it is called one to many relationship.
•For example – a customer can place many orders but a order cannot be
placed by many customers.

26
3. Many to One Relationship
•When more than one instances of an entity is associated with a single
instance of another entity then it is called many to one relationship.
•For example – many students can study in a single college but a
student cannot study in many colleges at the same time.

27
4. Many to Many Relationship
•When more than one instances of an entity is associated with more
than one instances of another entity then it is called many to many
relationship.
• For example, a can be assigned to many projects and a project can be
assigned to many students.

28
How to Create an Entity Relationship
Diagram (ERD)

29
In a university, a Student enrolls in Courses. A student must be
assigned to at least one or more Courses. Each course is taught by a
single Professor. To maintain instruction quality, a Professor can
deliver only one course

Step 1) Entity Identification


•We have three entities
•Student
•Course
•Professor

Student Course Professor

30
Step 2) Relationship Identification
We have the following two relationships
•The student is assigned a course
•Professor delivers a course

assig deliv
Student ned Course ers Professor

31
Step 3) Cardinality Identification
For them problem statement we know that,
•A student can be assigned multiple courses
•A Professor can deliver only one course

1 assig M deliv
Student ned Course ers Professor

32
Step 4) Identify Attributes:

33
Course_id Emp_id
Stud_id

1 M
assig deliv
Student ned Course ers Professor

Stud_name Course_name Prof_name

34
• Hospital ER Model

35
• Company ER Model

36
Keys

• We must have a way to specify how entities within a given entity


set are distinguished.

• Conceptually, individual entities are distinct; from a database


perspective, however, the differences among them must be
expressed in terms of their attributes.

• Therefore, the values of the attribute values of an entity must be


such that they can uniquely identify the entity.

• In other words, no two entities in an entity set are allowed to have


exactly the same value for all attributes.

37
Keys
• That is, a key for an entity is a set of attributes that suffice to
distinguish entities from each other.

• A Key can be a single attribute or a group of attributes

• The concepts of superkey, candidate key, and primary key are


applicable to entity sets just as they are applicable to relation
schemas.

• Keys also help to identify relationships uniquely, and thus


distinguish relationships from each other.

38
Keys
student_id name phone age
1 Akon 9876723452 17
2 Akon 9991165674 19
3 Bkon 7898756543 18
4 Ckon 8987867898 19
5 Dkon 9990080080 17

Super Key
• Super Key is defined as a set of attributes within a table that can uniquely
identify each record within a table. Super Key is a superset of Candidate
key.
• In the table defined above super key would include student_id, (student_id,
name), phone etc.

39
Entity-Relationship Diagrams

• An E-R diagram can express the overall logical structure of a


database graphically.

• E-R diagrams are simple and clear.

40
Entity-Relationship Diagrams
Basic Structure
An E-R diagram consists of the following major components:

•Rectangles divided into two parts represent entity sets.


– The first part, which is shaded blue, contains the name of the
entity set.
– The second part contains the names of all the attributes of the
entity set.

•Diamonds represent relationship sets.

•Undivided rectangles represent the attributes of a relationship set.

41
Entity-Relationship Diagrams

42
Entity-Relationship Diagrams
• Attributes that are part of the primary key are underlined.

• Lines link entity sets to relationship sets.

• Dashed lines link attributes of a relationship set to the


relationship set.

• Double lines indicate total participation of an entity in a


relationship set.

• Double diamonds represent identifying relationship sets linked to


weak entity sets.

43
Entity-Relationship Diagrams
• Consider the E-R diagram in Figure 7.7, which consists of two
entity sets, instructor and student related through a binary
relationship set advisor.

• The attributes associated with instructor are ID, name, and salary.

• The attributes associated with student are ID, name, and tot cred.

• In Figure 7.7, attributes of an entity set that are members of the


primary key are underlined.

44
Entity-Relationship Diagrams
• If a relationship set has some attributes associated with it, then we
enclose the attributes in a rectangle and link the rectangle with a
dashed line to the diamond representing that relationship set.

• For example, in Figure 7.8, we have the date descriptive attribute


attached to the relationship set advisor to specify the date on
which an instructor became the advisor.

45
Entity-Relationship Diagrams
• Mapping Cardinality
• The relationship set advisor, between the instructor and student
entity sets may be one-to-one, one-to-many, many-to-one, or
many-to-many.

• To distinguish among these types, we draw either a directed line


(→) or an undirected line (—) between the relationship set and
the entity set in question, as follows:

46
Entity-Relationship Diagrams
• One-to-one: We draw a directed line from the relationship set
advisor to both entity sets instructor and student (see Figure 7.9a).
• This indicates that an
– instructor may advise at most one student, and
– a student may have at most one advisor.

47
Entity-Relationship Diagrams
• One-to-many: We draw a
– directed line from the relationship set advisor to the entity set
instructor and
– an undirected line to the entity set student (see Figure 7.9b).
• This indicates that an instructor may advise many students, but a
student may have at most one advisor.

48
Entity-Relationship Diagrams
• Many-to-one:
– We draw an undirected line from the relationship set advisor
to the entity set instructor and
– a directed line to the entity set student.

• This indicates that an instructor may advise at most one student,


but a student may have many advisors.

49
Entity-Relationship Diagrams
• Many-to-many: We draw an
– undirected line from the relationship set advisor to both entity
sets instructor and student (see Figure 7.9c).
– This indicates that an instructor may advise many students,
and a student may have many advisors.

50
Entity-Relationship Diagrams

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
References

• Disjoint example
--https://www2.cs.sfu.ca/CourseCentral/354/zaiane/material/notes/C
hapter2/node2.html

• https://searchwindowsserver.techtarget.com/definition/disjoint-
namespace

88
End of Chapter 2

89
E-R Diagram for Exercise 2.10

90
E-R Diagram for Exercise 2.15

91
E-R Diagram for Exercise 2.22

92
E-R Diagram for Exercise 2.15

93

You might also like