Chapter 3 Data Modeling Using The Entity-Relationship (ER) Model-15!05!2021
Chapter 3 Data Modeling Using The Entity-Relationship (ER) Model-15!05!2021
The data requirements is a detailed and complete form of data requirements are
used as a source of database design.
In parallel with specifying the data requirements, it is useful to specify the
known functional requirements of the application. Functional requirements
consist of user defined operations that will be applied to the database,
including retrievals and updates.
Functional requirements can be documented using diagrams such as sequence
diagrams, data flow diagrams, scenarios, etc.
Step 2: Conceptual Design: Once all the requirements have been collected and
analyzed, the next step is to create a conceptual schema for the database,
using a high level conceptual data model. This phase is called conceptual
design (Conceptual design is also called as conceptual schema).
Conceptual schema: brief description of data requirements of the users and
includes a detailed description of the entity types, relationships and
constraints. Conceptual schema concepts do not include implementation details;
therefore the end users easily understand them, and they can be used as a
communication tool. The conceptual schema is used to ensure all user
requirements are met, and they do not conflict.
Step 4: Physical Design: Physical design is the last phase of database design.
The goal of the physical design is to implement the actual database. At this
phase one must know which database management system (DBMS) is used. For
example, different DBMS's have different names for datatypes and have
different datatypes.
The SQL clauses to create the database are written. The indexes, the integrity
constraints (rules) and the users' access rights are defined. Finally the data
to test the database is added in.
In parallel with these activities, application programs are designed. The
implementation of the programs can start when the database is created and data
has been added in.
Entity
Attribute: Attributes are the descriptive properties which are owned by each
entity (An attribute is a real world property or characteristic of an entity).
Attribute is the name of the column. An entity may contain any number of
attributes. One of the attributes is considered as the primary key. In an
Entity-Relation model, attributes are represented in an oval or ellipse
(elliptical) symbol. Every ellipse represents one attribute and is directly
connected to its entity (rectangle).
For example: In Bank database, Customer is considered as one entity and
customer entity describes various data elements (data field, a field, a data
item, or an elementary item) such as name, address, customer ID number. These
data elements are called as attributes of customer entity in bank database.
Strong Entity
The ROLLNO in Student entity will identify the each student uniquely. So,
ROLLNO is set to be the Primary Key of the STUDENT entity, & Hence STUDENT is
a strong entity type because has its own key attribute ROLLNO.
Weak Entity:
Entity type doesn’t have any key attribute or Primary Key of its
own is called weak entity Type. Weak entity depends on other strong entity via
foreign key. A weak Entity is represented using double rectangular boxes.
Weak Entity
Children Entity is depending upon Strong Entity Employee (as it has a unique
ID named SSN). The relationship is established to associate children with
their parents for insurance coverage.
Attributes of CHILDREN entity are-
CNAME (name of Child)
Age of Child
Type of Insurance
So, none of the attributes of CHILDREN does not give a unique ID to the
entity. And the CHILDREN Entity has to depend on EMPLOYEE entity for
identification.
Composite Entity:
Entities participating in the many to many relationships are
called composite entity. In this case, apart from two entities that are part
of relation, we will one more hidden entity in the relation. We will be
creating a new entity with the relation, and create a primary key by using the
primary keys of other two entities.
Consider the example, multiple students enrolled for multiple courses. In this
case, we create STUDENT and COURSE. Then we create one more table for the
Recursive Entity:
If a relation exists between the same entities, then such
entities are called as recursive entity. For example, mapping between manager
and employee is recursive entity. Here manager is mapped to the same entity
Employee. HOD of the department is another example of having recursive entity.
For example: A supervisor and subordinate relationship sets-one Supervisor can
supervise multiple subordinates but each subordinate reporting to at most one
supervisor.
For example, each user can have several different hobbies, therefore the
“hobby” can be considered as a multivalued attribute for the “user”
entity:
For example, the Address attribute consists of several domains such as house
number, street number, city, country, etc.
Derived attribute: Derived attributes are the attributes that do not exist in
the physical database (The derived attribute may or may not be physically
stored in the database), but their values are derived from other attributes
present in the database.
If an attribute’s value can be determined from the values of other
attributes, then the attribute is derivable, and is said to be a derived
attribute.
These attributes are derived from other attributes. It can be derived from
multiple attributes and also from a separate table. To represent a derived
attribute, another dotted ellipse is created inside the main ellipse.
For example, having given the price excluding VAT and the VAT rate, we can
calculate the price including VAT:
Key Attribute:
It is an attribute that has primary key to distinct value for
each entity/element in an entity set. The name of a key attribute is
underscored
For example, since the Vehicle Identification Number (VIN) is a unique code
used to identify individual vehicles (no two vehicles have the same VIN),
“VIN” can be considered as the key attribute for the “CAR” entity:
Some entity types have more than one key attribute. For example, each of
the Vehicle_id and Registration attributes of the entity type CAR is a
key in its own right.
Value sets (Domains) of Attributes: A set of values that may be assigned to
the attributes of each individual entity, in an entity set is called the value
set or domain.
For example: in employee entity, if age limit is 25 to 58 then the value set
(domain) of attribute age consist of integer from 25 to 58. The value set for
name attribute is a set of alphabets and some special characters such as [a-
z], [A-Z], blank space and dot.
Initial Conceptual Design of the COMPANY Database:
An entity
type DEPARTMENT with attributes Name, Number, Locations, Manager, and
Manager_start_date. A location is the only multivalued attribute. We can
specify that both Name and Number are (separate) key attributes because
each was specified to be unique.
An entity type PROJECT with attributes Name, Number, Location,
and Controlling_department. Both Name and Number are (separate) key
attributes.
An entity type EMPLOYEE with
attributes Name, Ssn, Sex, Address, Salary,
Relationship represents an association between two or more entities.
An example of a relationship would be:
Employees are assigned to projects
Projects have subtasks
Departments manage one or more projects
Consider the following diagram that shows two entity types (Department and
Instructor) and the concept (a relationship) that instructors work in
departments. This relationship involves two entity types and is referred to as
a binary relationship.
Unary Relationship:
When there is only ONE entity set participating in a
relation, An entity type linked with itself that type of relationship is
called as unary relationship. Unary relationship is also called as
recursive relationship.
For example, one person is married to only one person.
Example: Roommate, where STUDENT is linked with STUDENT
Binary Relationship:
When there are TWO entities set participating in a
relation, a one Entity type linked with another entity type that type of
relationship is called as binary relationship. The degree of binary
relationship is 2.
For example, Student is enrolled in Course.
Ternary Relationship:
N-ary Relationship:
When there are n entities set participating in a
relation, the relationship is called as n-ary relationship.
The most common relationship in ER diagram is Binary Relationship.
Relationships as Attributes:
It is sometimes convenient to think of a binary
relationship type in terms of attributes.
Consider the WORKS_FOR relationship type in Figure 7.9.
One can think of an attribute called Department of the EMPLOYEE entity type,
where the value of Department for each EMPLOYEE entity is (a reference to) the
DEPARTMENT entity for which that employee works. Hence, the value set for this
Department attribute is the set of all
DEPARTMENT entities, which is the DEPARTMENT entity set. This is what we did
in Figure 7.8 when we specified the initial design of the entity type EMPLOYEE
for the COMPANY database. However, when we think of a binary relationship as
an attribute, we always have two options. In this example, the alternative is
to think of a multivalued attribute Employee of the entity type DEPARTMENT
whose values for each DEPARTMENT entity is the set of EMPLOYEE entities who
work for that department.
The value set of this Employee attribute is the power set of the EMPLOYEE
entity set. Either of these two attributes—Department of EMPLOYEE or Employee
of DEPARTMENT—can represent the WORKS_FOR relationship type. If both are
represented, they are constrained to be inverses of each other.8
Role Names:
Each entity type that participates in a relationship type plays a
particular role in the relationship. The role name signify the role that a
participating entity from the entity type plays in each relationship instance,
and helps to explain what the relationship means.
Role names are not technically necessary in relationship types where all the
participating 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.
For example:- in the WORKS_FOR relationship type, EMPLOYEE plays the role of
employee or worker and DEPARTMENT plays the role of department or employer.
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.
It is about the maximum number of entities of one entity set that are
associated with the maximum number of entities of the other entity set.
For example:
Let us assume a student entity set (student’s information)
and course entity set (courses that are registered by a student).
To establish a link (relationship) between these two entity sets we need to
define the number of entities (records) of student that are associated with
number of entities (records) of course.
One-to-one relationship:
If an entity [a record] of one
entity set A is associated with at most one entity in entity set B and entity
in entity set B is associated with at most one entity in entity set A. this
type of cardinality is called as one-to-one relationship (cardinality).
One-to-One Relationship is represented 1:1.
Example:
Let us assume a database for Airline Reservation System. Further assume that
there are two entity sets Passengers and Boarding-Pass represent the passenger
details and the flight tickets details respectively. If it is decided to issue
each passenger a boarding pass, then the relationship between the entity sets
Passengers and Boarding-Pass will be One-to-one.
As shown in the figure below, each passenger is allotted only one seat. Each
passenger entity is associated with exactly one Boarding_Pass entity.
A country has only one capital city, and a capital city is the capital of only
one country.
Each student fills one seat and one seat is assigned to only one
student.
Each professor has one office space.
The above example describes that one student can enroll only for one course
and a course will also have only one Student. This is not what you will
usually see in real-world relationships.
When we would say the relationship is one-to-one?
Assume two entity sets A and B. The
relationship between A and B is one-to-one if and only if “an entity in A is
associated with only one entity (record) in B and an entity in B is associated
with only one entity (record) in A”.
If we put in simpler terms, entity set B is the one side for A and entity
set A is the one side for B.
One-to-Many relationship:
If an entity [a record] of one
entity set is associated with zero or more entities of the other entity set,
then the cardinality ratio is said to be one-to-many from one side entity set
to the many side entity set.
Example:
1 student can opt for many courses, but a course can only
have 1 student. Sounds weird! This is how it is.
Example:
Let us assume a database for Airline Reservation System.
Further assume that there are two entity sets Flights and Flight_Attendants to
model the flight details and the flight attendants details respectively. If
one flight can have many attendants, then this relationship can be modeled as
one-to-many from Flight to Flight_Attendants.
Example:
Student enrolls for only one Course but a Course can have
many Students.
Multiple entities of the first set are related to one entities of the second
set. E.g. Teachers teach a student. Many teachers are teaching only one
student. This can be expressed in the following diagram as:
Example:
Teachers teach students. In any school or college many
teachers are teaching many students. This can be considered as a two way
many-to-many relationship. This can be expressed in the following diagram as:
The above diagram represents that one student can enroll for more than one
courses. And a course can have more than 1 student enrolled in it.
Cardinality ratios for binary relationships are represented on ER
diagrams by displaying 1, M, and N on the diamonds.
Participation Constraints and Existence Dependencies:
What is Participation Constraints?
Partic
ipation Constraint is a type of relationship constraint. The participation
constraint specifies (describes) whether the existence of an entity depends on
its being related to another entity via the relationship type. (It describes
that whether the existence of an entity is dependent on its relationship with
another entity via the relationship type).
This constraint specifies the minimum number of relationship instances that
each entity can participate in.
There are two kinds of participation constraints.
1. Total Participation
2. Partial Participation
Total Participation:
Total Participation is when each entity in the
entity set occurs in at least one relationship in that relationship set.
After specifying the above six relationship types, we remove from the entity
types in Figure 7.8 all attributes that have been refined into relationships.
These include Manager and Manager_start_date from DEPARTMENT;
Controlling_department from PROJECT; Department, Supervisor, and Works_on from
EMPLOYEE; and Employee from DEPENDENT. It is important to have the least
possible redundancy when we design the conceptual schema of a database.
ER Diagrams, Naming Conventions, and Design Issues
Summary of Notation for ER Diagrams:
ERD attribute symbols: ERD attributes are characteristics of the entity that
help users to better understand the database. Attributes are included to
include details of the various entities that are highlighted in a conceptual
ER diagram.
Attribute
Name Description
Symbol
An entity is
represented by a
Entity rectangle which
contains the
entity’s name.
An entity that
cannot be
uniquely
identified by its
attributes alone.
The existence of
a weak entity is
dependent upon
another entity
Weak Entity called the owner
entity. The weak
entity’s
identifier is a
combination of
the identifier of
the owner entity
and the partial
key of the weak
entity.
Relationships
A relationship
where entity is
existence-
independent of
other entities,
and PK of Child
Strong
doesn’t contain
relationship
PK component of
Parent Entity. A
strong
relationship is
represented by a
single rhombus
A relationship
where Child
entity is
existence-
dependent on
Weak parent, and PK of
(identifying) Child Entity
relationship contains PK
component of
Parent Entity.
This relationship
is represented by
a double rhombus.
Entity Relationship Diagram Symbols — Crow’s Foot notation
Symbol Meaning
Zero or One
Zero or More
Many - to - One
a one through many
notation on one side
of a relationship and
a one and only one on
the other
a zero through many
notation on one side
of a relationship and
a one and only one on
the other
a one through many
notation on one side
of a relationship and
a zero or one
notation on the other
a zero through many
notation on one side
of a relationship and
a zero or one
notation on the other
Many - to - Many
a zero through many
on both sides of a
relationship
a zero through many
on one side and a one
through many on the
other
a one through many on
both sides of a
relationship
Next, consider the attributes that you need to describe each entity. These are
drawn and labeled inside ovals. Connect these to the relevant entity and
Now, think through the relationships or verbs taking place within your system.
The easiest way to do this is to look at each entity and try to connect it to
PUTTASWAMY B. S. Assistant Professor, Dept. of IS&E, PESCE Mandya Page 88
DATA BASE MANAGEMENT SYSTEM (P18IS42)
another by saying, “What does the ___ do with the ___.” The customer
purchases the phone. The cell service maintains the phone. The cell service
creates a bill. The customer pays the bill.
4. Add Cardinality to Every Relationship