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

The Enity Relationship Model

The document discusses database design using the entity-relationship (E-R) model. It begins by introducing the E-R model and its use for identifying entities, their attributes, and relationships to design a database schema. It then provides details on key aspects of the E-R model including entities, attributes, relationships, cardinality, weak entities, and how to represent these concepts in E-R diagrams. Examples of E-R diagrams are also presented for a blog application, insurance company, and patient management system.

Uploaded by

cleophacerevival
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

The Enity Relationship Model

The document discusses database design using the entity-relationship (E-R) model. It begins by introducing the E-R model and its use for identifying entities, their attributes, and relationships to design a database schema. It then provides details on key aspects of the E-R model including entities, attributes, relationships, cardinality, weak entities, and how to represent these concepts in E-R diagrams. Examples of E-R diagrams are also presented for a blog application, insurance company, and patient management system.

Uploaded by

cleophacerevival
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

DATABASE DESIGN AND

THE E-R MODEL


Introduction
So far we have assumed a given database schema and studied
how queries and updates are expressed.

We now consider how to design a database schema in the first


place. We focus on the entity relationship data model (E-R),
which provides a means of identifying entities to be
represented in the database and how those entities are related.

We then show how an E-R design can be transformed into a set


of relational schemas ready for implementation in your DBMS
of choice.
Introduction…
The task of creating a database application is a complex one.

For small applications a database designer may understand the application


requirements to decide directly on the entities/relations to be created, their
attributes, and constraints to be applied.

However, for complex apps, their databases are often highly complex.
Often no one person understands the complete data needs of the
application.

The database designer must interact with users of the application or


domain experts to understand the needs of the application, represent them
in a high-level fashion that can be understood by the users, and then
translate the requirements into lower levels of the design.
Entity Relationship Model
The entity-relationship data model is a model that
perceives the real world as consisting of basic objects
(things), called entities and relationships among these
objects (things).

It was developed to facilitate database design by


allowing specification of an enterprise schema which
represents the overall logical structure of a data base.

ER Model is used to model the logical view of the system


from data perspective
Main features of ER-MODEL:
Entity relationship model is a high level conceptual model
It allows us to describe the data involved in a real world
enterprise in terms of objects and their relationships.
 It is widely used to develop an initial design of a
database
 It provides a set of useful concepts that make it
convenient for a developer to move from a basic set of
information to a detailed and description of information
that can be easily implemented in a database system
 It describes data as a collection of entities, relationships
and attributes.
ENTITY RELATIONSHIP DIAGRAMS (ERD)
E-R diagrams express the overall logical structure of a
database graphically. E-R diagrams are simple and clear.

E-R Diagrams use special symbols which we will see


shortly.
1. ENTITY
An Entity may be an object with a physical existence – a
particular person, car, house, or employee – or it may be
an object with a conceptual existence – a company, a job,
or a university course.

In ER diagram, Entity Type is represented using a


rectangle.

Student Course
2. ENTITY SET
An entity set is a set of entities of the same type that
share the same properties.
Example: Computer Science students are an entity set of
the entity student. Physics, Chemistry and Biology is an
entity set of the entity course.
Diagrammatically represented by a vertical oval:

Amina
Boniface Entity set of Student entity
Aisha
3. ATTRIBUTE
Attributes are the properties of an entity. For example,
Roll_No, Name, DOB, Age, Address, Mobile_No are the
attributes of the entity Student. In ER diagram, attribute
is represented by an oval.

Name
3.1 KEY ATTRIBUTE
The attribute which uniquely identifies each entity in the
entity set is called key attribute. For example ID of student is
unique for each student. In ER diagram, key attribute is
represented by an oval with underlying lines.

ID
3.2 COMPOSITE ATTRIBUTE
An attribute composed of many other attribute is called as composite
attribute. For example, Address attribute of student Entity consists of Street,
City, State, and Country. In ER diagram, composite attribute is represented by an
oval comprising of ovals.
3.3 MULTIVALUED ATTRIBUTE
An attribute consisting more than one value for a given entity. For example,
Phone_No (can be more than one for a given student). In ER diagram,
multivalued attribute is represented by double oval.
3.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.
The complete entity Student with its attributes can be
represented as:
4. RELATIONSHIP
A relationship represents the association between
entities. For example, ‘Enrolled in’ is a relationship type
that exists between entity type Student and Course. In
ER diagram, relationship type is represented by a
diamond and connecting the entities with lines.
4. RELATIONSHIP…
A relationship can also have an attribute. Consider a
movie renting app. The relationship Rent has an
attribute called Rent_Date which is the date the movie
was rented. Some people call these relationships that
have attributes as Associative Entities
4.1 RELATIONSHIP SET
A set of relationships of same type is known as
relationship set. The following relationship set depicts S1
is enrolled in C2, S2 is enrolled in C1 and S3 is enrolled
in C3.
4.2 DEGREE OF 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.
4.2 DEGREE OF RELATIONSHIP SET…
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.
4.2 DEGREE OF RELATIONSHIP SET…
3. n-ary Relationship –
When there are n entities set participating in a
relation, the relationship is called as n-ary
relationship. For example if n is 3, the relationship is
called ternary relationship.

In this course we focus only on unary and binary


relationships.
5. CARDINALITY
Cardinality expresses the number of entities to which
another entity can be associated via a relationship set.

Most useful in describing binary relationship sets.

For a binary relationship set the mapping cardinality


must be one of the following types:
 One to one
 One to many

 Many to one

 Many to many
5.1 ONE-TO-ONE
A single entity of first entity set associates with single
entity of second entity set.

For example, a relationship between person and


passport entities is one to one because a person can
have only one passport and a passport can be assigned to
only one person.
5.2 ONE-TO-MANY
A single entity of first entity set can associate with more
than one entity of second entity set.

For example, relationship between customer and order


entities is one to many because a customer can place
many orders but a order can be placed by a single
customer alone.
5.3 MANY-TO-ONE
Many entities of first entity set associate with single
entity of second entity set.

For example, relationship between student and


university is many to one because a university can have
many students but a student can only study only in
single university at a time.
5.4 MANY-TO-MANY
Many entities of first entity set can associate with many
entities of second entity set

For example, relationship between student and course


entities is many to many because a student can take
many courses at a time and a course can be assigned to
many students.
Cardinality in set notation
Cardinality in set notation
Note: The above notation of drawing ERD using
rectangles and Diamonds is known as Chen notation.
(It was developed by Peter Chen)
There is another notation of drawing ERDs known as
Crow’s foot notation (You can read about this on your
own here)
Crows Foot Notation
Crows Foot Notation
6. PARTICIPATION CONSTRAINTS
Participation Constraint is applied on the entity
participating in the relationship set.
1. Total Participation – Each entity in the entity set must
participate in the relationship. If each student must
enroll in a course, the participation of student will be total.
Total participation is shown by double line in ER diagram.
2. Partial Participation – The entity in the entity set may
or may NOT participate in the relationship. If some
courses are not enrolled by any of the student, the
participation of course will be partial.
6. PARTICIPATION CONSTRAINTS…
The diagram below depicts the ‘Enrolled in’ relationship
set with Student Entity set having total participation
and Course Entity set having partial participation.
7. WEAK ENTITY
A weak entity is an entity that cannot be uniquely identified by
its attributes alone i.e. An entity that does not have a unique
attribute.

An entity that can be uniquely identified by its attributes is


called a Strong Entity.

For example, a company may store the information of


dependents (Parents, Children, Spouse) of an Employee. But
the dependents don’t have existence without the employee. So
Dependent is a weak entity type and Employee entity is called
the Identifying Entity or Owner Enity
7. WEAK ENTITY…
A weak entity type is represented by a double rectangle.
The participation of weak entity type is always total. The
relationship between weak entity type and its
identifying strong entity type is called Identifying
Relationship and it is represented by double diamond.
7. WEAK ENTITY…
Another example of a weak entity is loan entity. A loan
cannot exist without a customer.
ERD OF A BLOG APP
ERD for a blog application (web or mobile). In this blog users register into the
system and upload blog posts that have a title, an image and a body. Example of
a simple blog website is https://open-api.xyz/
ERD OF INSURANCE CAR COMPANY
ERD OF A PATIENT MGMT SYSTEM
You can read more about ER Model
here

You might also like