Académique Documents
Professionnel Documents
Culture Documents
Introduction to ER Model
ER model represents real world situations using concepts, which are commonly used by people.
It allows defining a representation of the real world at logical level.ER model has no facilities to
describe machine-related aspects. In ER model the logical structure of data is captured by
indicating the grouping of data into entities. Diagrammatic representation of ER model is called
ER Diagram.
1
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Requirements Collection and Analysis:
o purpose is to produce a description of the users' requirements. During this
step the database designers interview prospective database users to
understand and document their data requirements. The result of this step is
written set of user’s requirements.
o In parallel with specifying the data requirements, it is useful to specify
the known functional requirements of the application. These consists of
user defined operations that is applied to the database, including both
retrievals and updates.
o Data flow diagrams, sequence diagrams and other techniques can be used
to specify functional requirements.
Conceptual Design:
o purpose is to produce a conceptual schema for the database, including
detailed descriptions of entity types, relationship types, and constraints.
All these are expressed using a high level conceptual data model.
o These concepts do not include implementation details. They are easier to
understand and can be used to communicate with non technical users
o The high level conceptual schema can also be used as a reference to
ensure that all user’s data requirements are met and the requirements do
not conflict.
o This approach enables the database designers to concentrate on specifying
the properties of the data without concerned with storage details.
o During or after the conceptual schema design, the basic data model
operations can be used to specify the high level user operations identified
during functional analysis.
Logical design :
o purpose is to transform the conceptual schema (which is at a high/abstract
level) into a (lower-level) representational/implementation model
supported by whatever DBMS is to be used.
o Most commercial DBMS use an implementation data model such as
relational or object relational database model.
Physical Design: purpose is to decide upon the internal storage structures, access paths
(indexes), etc., that will be used in realizing the representational model produced in
previous phase.
` In parallel with these activities, application programs are designed and implemented as
database transactions corresponding to the high level transaction specification.
2
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Entity Types, Entity sets, Attributes, keys
Entity
o An entity is an object in the real world that is distinguishable from other objects.
o It is a thing in the real world with an independent existence.
o An entity may be
An object with physical existence(ex, person, car, house, employee)
Or it may be an object with conceptual existence(ex: a company, a job. Or
a university course).
3
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
1. Strong Entity Set-
A strong entity set is an entity set that contains sufficient attributes to uniquely identify all its
entities.
In other words, a primary key exists for a strong entity set.
Primary key of a strong entity set is represented by underlining it.
Symbols Used-
A single rectangle is used for representing a strong entity set.
A diamond symbol is used for representing the relationship that exists between two strong
entity sets.
A single line is used for representing the connection of the strong entity set with the
relationship set.
A double line is used for representing the total participation of an entity set with the
relationship set.
Total participation may or may not exist in the relationship.
Example-
Consider the following ER diagram-
In this ER diagram,
Two strong entity sets “Student” and “Course” are related to each other.
Student ID and Student name are the attributes of entity set “Student”.
Student ID is the primary key using which any student can be identified uniquely.
Course ID and Course name are the attributes of entity set “Course”.
Course ID is the primary key using which any course can be identified uniquely.
Double line between Student and relationship set signifies total participation.
It suggests that each student must be enrolled in at least one course.
Single line between Course and relationship set signifies partial participation.
It suggests that there might exist some courses for which no enrollments are made.
4
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
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.
Symbols Used-
A double rectangle is used for representing a weak entity set.
A double diamond symbol is used for representing the relationship that exists between the
strong and weak entity sets and this relationship is known as identifying relationship.
A double line is used for representing the connection of the weak entity set with the
relationship set.
Total participation always exists in the identifying relationship.
Example-
Consider the following ER diagram-
5
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Differences between Strong entity set and Weak entity set-
A single rectangle is used for the representation A double rectangle is used for the representation
of a strong entity set. of a weak entity set.
It contains sufficient attributes to form its It does not contain sufficient attributes to form
primary key. its primary key.
A diamond symbol is used for the representation A double diamond symbol is used for the
of the relationship that exists between the two representation of the identifying relationship that
strong entity sets. exists between the strong and weak entity set.
Attribute
Attribute: An entity is described by its attributes, which are properties that describe entities.
Each attribute has a value drawn from some domain (set of meaningful values). Example: A
PERSON entity might be described by Name, Birth Date, Sex, etc., attributes, each having a
particular value.
6
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
1. Simple/atomic vs. composite attributes
Simple/Atomic Attributes :
The attributes which cannot be divided into smaller subparts are called simple or atomic
attributes. For example, age of employee entity
To describe the structure of a composite attribute, one can draw a tree (Figure 3.4).. For the
examples mentioned above, we would write BirthDate(Month, Day, Year)
Address(StreetAddr(StrNum, StrName, AptNum), City, State, Zip)
Single valued Attributes : An attribute, that has a single value for a particular
entity. For example, SSN,DOB,age of an employee entity.
Multi valued Attributes : An attributes that may have multiple values for the
same entity. For example colors of a car entity, zero or more academic degree .
7
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
multiple phones, an addressphone for a person entity can be specified as –
{Addressphone (phone {(Area Code, Phone Number)}, Address(Sector Address
(Sector Number,House Number), City, State, Pin))}
Here {} are used to enclose multivalued attributes and () are used to enclose composite
attributes with comma separating individual attributes.
The Null value: In some cases a particular entity might not have an applicable value for a
particular attribute. Or that value may be unknown. Or, in the case of a multi-valued attribute, the
appropriate value might be the empty set. Example: The attribute DateOfDeath is not applicable
to a living person and its correct value may be unknown for some persons who have died. In
such cases, we use a special attribute value (non-value?), called null. There has been some
argument in the database literature about whether a different approach (such as having distinct
values for not applicable and unknown) would be superior.
Attributes in ER Diagram-
Attributes are the descriptive properties which are owned by each entity of an Entity Set.
There exist a specific domain or set of values for each attribute from where the attribute can
take its values.
types of Attributes-
In ER diagram, attributes associated with an entity set may be of the following types-
8
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
1. Simple attributes
2. Composite attributes
3. Single valued attributes
4. Multi valued attributes
5. Derived attributes
6. Key attributes
1. Simple Attributes-
Simple attributes are those attributes which can not be divided further.
Example-
Here, all the attributes are simple attributes as they can not be divided further.
2. Composite Attributes-
Composite attributes are those attributes which are composed of many other simple attributes.
Example-
9
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Here, the attributes “Name” and “Address” are composite attributes as they are composed of
many other simple attributes.
3. Single Valued Attributes-
Single valued attributes are those attributes which can take only one value for a given entity
from an entity set.
Example-
Here, all the attributes are single valued attributes as they can take only one specific value for
each entity.
4. Multi Valued Attributes-
Multi valued attributes are those attributes which can take more than one value for a given entity
from an entity set.
Example-
Here, the attributes “Mob_no” and “Email_id” are multi valued attributes as they can take more
than one values for a given entity.
5. Derived Attributes-
Derived attributes are those attributes which can be derived from other attribute(s).
Example-
10
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Here, the attribute “Age” is a derived attribute as it can be derived from the attribute “DOB”.
6. Key Attributes-
Key attributes are those attributes which can identify an entity uniquely in an entity set.
Example-
Here, the attribute “Roll_no” is a key attribute as it can identify any student uniquely.
11
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Relationship
Relationship Set-
A relationship set is a set of relationships of same type.
Example-
Set representation of above ER diagram is-
12
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
1. Unary relationship set
2. Binary relationship set
3. Ternary relationship set
4. N-ary relationship set
1. Unary Relationship Set-
Unary relationship set is a relationship set where only one entity set participates in a relationship
set.
2. Binary Relationship Set-
Binary relationship set is a relationship set where two entity sets participate in a relationship set.
13
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Cardinality ratio for binary relationship
The mapping cardinalities or the cardinality ratio represents the number of
relationship instances that an entity can participate in, i.e. the number of entities to
which another entity can be associated via a relationship set. In other words,
number of entities in one entity set which can be associated with the number of
entities of other set via relationship set. Mapping cardinalities are most useful in
describing binary relationship sets.
For a binary relationship set R between entity sets A and B, the mapping cardinality
must be one of the following –
15
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Participation constraints and Existence Dependencies
The participation constraint specifies whether the existence of an entity depends on its being
related to another entity via the relationship type. This constraint specifies the minimum number
of relationship instances that each entity can participate in, and is sometimes called the minimum
cardinality constraint.
There are two types of participation constraints-
Partial Participation
It specifies that each entity in the entity set may or may not participate in the relationship
instance in that relationship set.
That is why, it is also called as optional participation.
Partial participation is represented using a single line between the entity set and relationship
set.
16
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
For example
structural constraints
Cardinality ratio and participation constraints, together is called as structural constraints of a
relationship type.
Role names
Role names are not technically necessary in relationship types where all the partici-
pating entity types are distinct, since each participating entity type name can be used as
the role name.
However, in some cases the same entity type participates more than once in a relationship
type in different roles. In such cases the role name becomes essential for distinguishing
the meaning of the role that each participating entity plays. Such relationship types are
called recursive relationships.
17
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
In a recursive relationship type. Both participations are same entity type in different roles.F or
example, SUPERVISION relationships between EMPLOYEE (in role of supervisor or boss) and
(another) EMPLOYEE (in role of subordinate or worker).In following figure, first role
participation labeled with 1 and second role participation labeled with 2.In ER diagram, need to
display role names to distinguish participations.
18
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
for only one department, and hence participates in at most one relationship instance
in WORKS_FOR. In both 1:1 and 1:N relationship types, the decision where to place a
relationship attribute—as a relationship type attribute or as an attribute of a participating entity
type—is determined subjectively by the schema designer.
For M:N relationship types, some attributes may be determined by the combination of
participating entitiesin a relationship instance, not by any single entity. Such attributes must be
specified as relationship attributes. An example is the Hours attribute of the M:N
relationship WORKS_ON (Figure 7.13); the number of hours per week an employee currently
works on a project is determined by an employee-project combination and not separately by
either entity.
ER diagram
Different notations used in ER diagram
ER diagram or Entity Relationship diagram is a conceptual model that gives the graphical
representation of the logical structure of the database.
It shows all the constraints and relationships that exist among the different components.
Components of ER diagram-
An ER diagram is mainly composed of following three components-
1. Entity Sets
2. Attributes
3. Relationship Set
Example-
Consider the following Student table-
1 Akshay 20
2 Rahul 19
3 Pooja 20
19
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
4 Aarti 19
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-
Here,
Roll_no is a primary key that can identify each entity uniquely.
Thus, by using student’s roll number, a student can be identified uniquely.
ER Diagram Symbols-
An ER diagram is composed of several components and each component in ER diagram is
represented using a specific symbol.
ER diagram symbols are discussed below-
1. For Entity Sets-
An entity set is a set of same type of entities.
An entity refers to any object having- Either a physical existence such as a particular person,
office, house or car.
Or a conceptual existence such as a school or a company.
An entity set may be of the following two types-
20
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
2. Weak entity set
Strong Entity Set-
A strong entity set possess its own primary key.
It is represented using a single rectangle.
2. Weak Entity Set-
A weak entity set do not possess its own primary key.
It is represented using a double rectangle.
21
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
3. For Attributes-
Attributes are the properties which describes the entities of an entity set.
There are several types of attributes.
22
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
1. Partial participation
2. Total participation
1. Partial Participation-
Partial participation is represented using a single line between the entity set and relationship set.
2. Total Participation-
Total participation is represented using a double line between the entity set and relationship set.
23
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
24
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
25
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
26
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Model concept first as an attribute: A concept may be first modeled as an attribute
and then refined into a relationship because it is determined that the attribute is a
reference to another entity type.
Attribute that exists in several entity types may be elevated to an independent entity
type.
Example: suppose that several entity types in a university database such as
STUDENT, INSTRUCTOR and COURSE each has an attribute DEPARTMENT
in the initial design. The designer may choose to create an entity type department
with single attribute dept_name and relate it to three entities.
An inverse refinement to the previous case may be applied.
Example: Entity DEPARTMENT exists in the initial design with the attributer
dept_name and is related to other entity STUDENT. In this case DEPARTMENT
may be reduced to an attribute of STUDENT.
Examples:
A department has exactly one manager and an employee can manage at most one
department.
Specify (0,1) for participation of EMPLOYEE in MANAGES
Specify (1,1) for participation of DEPARTMENT in MANAGES
An employee can work for exactly one department but a department can have any
number of employees.
Specify (1,1) for participation of EMPLOYEE in WORKS_FOR
Specify (0,n) for participation of DEPARTMENT in WORKS_FOR
27
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
n- ary relationships(n>2)
In general, 3 binary relationships can represent different information than a single ternary
relationship (see Figure 3.17a and b ).If needed, the binary and n-ary relationships can all be
included in the schema design(see Figure 3.17a and b, where all relationships convey different
meanings). In some cases, a ternary relationship can be represented as a weak entity if the data
model allows a weak entity type to have multiple identifying relationships (and hence multiple
owner entity types) (see Fig 3.17c)
28
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
If a particular binary relationship can be derived from a higher-degree relationship at all times,
then it is redundant. For example, the TAUGHT_DURING binary relationship in Figure 3.18 can
be derived from the ternary relationship OFFERS (based on the meaning of the relationships).
29
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
SPECIALIZATION AND GENERALIZATION
30
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
EMPLOYEE/SECRETARY
EMPLOYEE/TECHNICIAN
EMPLOYEE/MANAGER
…
These two entities have two common attributes: Name and Address, we can make a generalized
entity with these common attributes. Lets have a look at the ER model after generalization.
The ER diagram after generalization:We have created a new generalized entity Person and
this entity has the common attributes of both the entities. As you can see in the following ER
diagram that after the generalization process the entities Student and Teacher only has the
specialized attributes Grade and Salary respectively and their common attributes (Name &
Address) are now associated with a new entity Person which is in the relationship with both the
31
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
entities (Student & Teacher).
Note:
1. Generalization uses bottom-up approach where two or more lower level entities combine
together to form a higher level new entity.
2. The new generalized entity can further combine together with lower level entity to create a
further higher level generalized entity.
32
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
Suppose that Requirements Collection and Analysis results in the following (informal)
description of the COMPANY mini world: The Company is organized as a collection of
departments.
Each department
has a unique name
has a unique number
is associated with a set of locations
has a particular employee who acts as its manager (and who assumed that position on
some date)
has a set of employees assigned to it
controls a set of projects
Each project
has a unique name
has a unique number
has a single location
has a set of employees who work on it
33
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
is controlled by a single department
Each employee
has a name
has a SSN that uniquely identifies her/him
has an address
has a salary
has a sex
has a birth date
has a direct supervisor
has a set of dependents
is assigned to one department
works some number of hours per week on each of a set of projects (which need not all be
controlled by the same department)
Each dependent
has first name
has a sex
has a birth date
is related to a particular employee in a particular way (e.g., child, spouse, pet)
is uniquely identified by the combination of her/his first name and the employee of
which (s)he is a dependent
Their initial design is shown below. The initial attributes shown are derived from the
requirements description
34
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
35
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
ER DIAGRAM
36
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
EMP
DEPEN
DENTS
-DF BOTTOM TO TOP
DEPENDENT
EMP
TOP TO BOTTOM
HAS
DEPENDENTS
37
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
38
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
39
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
40
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
ER diagram for AIRLINE Database
41
Kavitha J, Dept of CSE,RYMEC
Entity-Relationship Model
ER diagram for MOVIE Database
42
Kavitha J, Dept of CSE,RYMEC