0% found this document useful (0 votes)
16 views27 pages

Cpe3 Ds Module 3

Uploaded by

Carl Jasper Rabi
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)
16 views27 pages

Cpe3 Ds Module 3

Uploaded by

Carl Jasper Rabi
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/ 27

Module 3:

Entity Relationship
Model Basic Concepts
ER Model – Basic Concepts
The ER model defines the conceptual view of a database. It works around
real-world entities and the associations among them. At view level, the ER
model is considered a good option for designing databases.

Entity
An entity can be a real-world object, either animate or inanimate, that can be
easily identifiable. For example, in a school database: students, teachers,
classes, and courses offered can be considered as entities. All these entities
have some attributes or properties that give them their identity.

An entity set is a collection of similar types of entities. An entity set may contain
entities with attribute sharing similar values. For example, a Students Set may
contain all the students of a school; likewise a Teachers Set may contain all the
teachers of a school from all faculties. Entity sets need not be disjoint.
Attributes
Entities are represented by means of their properties called
attributes. All attributes have values. For example, a
student entity may have name, class, and age as attributes.

There exists a domain or range of values that can be assigned


to attributes. For example, a student's name cannot be a
numeric value. It has to be alphabetic. A student's age cannot be
negative, etc.
Types of Attributes
• Simple attribute: Simple attributes are atomic values, which cannot be divided further. For
example, a student's phone number is an atomic value of 10 digits.

• Composite attribute: Composite attributes are made of more than one simple attribute. For
example, a student's complete name may have first_name and last_name.

• Derived attribute: Derived attributes are the attributes that do not exist in the physical
database, but their values are derived from other attributes present in the database. For
example, age can be derived from date_of_birth.

• Single-value attribute: Single-value attributes contain single value. For example:


Social_Security_Number.

• Multi-value attribute: Multi-value attributes may contain more than one values. For example,
a person can have more than one phone_number, email_address, etc.
These attribute types can come together in a way like:

• simple single-valued attributes


• simple multi-valued attributes
• composite single-valued attributes
• composite multi-valued attributes
Entity – Set and Keys

Key is an attribute or collection of attributes that uniquely identifies an entity


among entity set.

For example, the student_number of a student makes him/her identifiable


among students.

Types of Keys in DBMS (Database Management System)

There are mainly Eight different types of Keys in DBMS and each key has it’s
different functionality: Super Key, Primary Key, Candidate Key, Alternate Key,
Foreign Key, Compound Key, Composite Key and Surrogate Key.
Types of Keys (https://www.guru99.com/dbms-keys.html)

• Super Key – A super key is a group of single or multiple keys which identifies rows in a table.
• Primary Key – is a column or group of columns in a table that uniquely identify every row in
that table.
• Candidate Key – is a set of attributes that uniquely identify tuples in a table. Candidate Key
is a super key with no repeated attributes.
• Alternate Key – is a column or group of columns in a table that uniquely identify every row in
that table.
• Foreign Key – is a column that creates a relationship between two tables. The purpose of
Foreign keys is to maintain data integrity and allow navigation between two different
instances of an entity.
• Compound Key – has two or more attributes that allow you to uniquely recognize a specific
record. It is possible that each column may not be unique by itself within the database.
• Composite Key – is a combination of two or more columns that uniquely identify rows in a
table. The combination of columns guarantees uniqueness, though individual uniqueness is
not guaranteed.
• Surrogate Key – An artificial key which aims to uniquely identify each record is called a
surrogate key. These kind of key are unique because they are created when you don’t have
any natural primary key.
Relationship
The association among entities is called a relationship. For example, an employee
works_at a department, a student enrolls in a course. Here, works_at and enrolls are
called relationships.

Relationship Set
A set of relationships of similar type is called a relationship set. Like entities, a relationship
too can have attributes. These attributes are called descriptive attributes.

Degree of Relationship
The number of participating entities in a relationship defines the degree of the relationship.
• Unary = degree 1
• Binary = degree 2
• Ternary = degree 3
• n-ary = degree
Binary Relationship and Cardinality

A relationship where two entities are participating is called a binary relationship.

Cardinality is the number of instance of an entity from a relation that can be


associated with the relation.
Mapping Cardinalities
• One-to-one − One entity from entity set • One-to-many − One entity from
A can be associated with at most one entity set A can be associated with
entity of entity set B and vice versa. more than one entities of entity
set B however an entity from
entity set B, can be associated
with at most one entity.
• Many-to-one − More than one
entities from entity set A can be • Many-to-many − One
associated with at most one entity entity from A can be
of entity set B, however an entity associated with more
from entity set B can be than one entity from B
associated with more than one and vice versa.
entity from entity set A.
One-to-one − when only one instance of an entity is associated
with the relationship, it is marked as '1:1'. The following image
reflects that only one instance of each entity should be associated
with the relationship. It depicts one-to-one relationship.
One-to-many − when more than one instance of an entity is
associated with a relationship, it is marked as '1:N'. The following
image reflects that only one instance of entity on the left and more
than one instance of an entity on the right can be associated with
the relationship. It depicts one-to-many relationship.
Many-to-one − when more than one instance of entity is
associated with the relationship, it is marked as 'N:1'. The following
image reflects that more than one instance of an entity on the left
and only one instance of an entity on the right can be associated
with the relationship. It depicts many-to-one relationship.
Many-to-many − The following image reflects that more than one
instance of an entity on the left and more than one instance of an
entity on the right can be associated with the relationship. It depicts
many-to-many relationship.
Participation Constraints
• Total Participation − each entity is involved in the relationship.
Total participation is represented by double lines.

• Partial participation − not all entities are involved in the


relationship. Partial participation is represented by single lines.
ER Diagram Representation
Let us now learn how the ER Model is represented by means of an ER diagram. Any
object, for example, entities, attributes of an entity, relationship sets, and attributes of
relationship sets, can be represented with the help of an ER diagram.

Entity
Entities are represented by means of rectangles. Rectangles are named with the entity set
they represent.

Relationship
Relationships, which are represented by diamond shapes, show how two entities share
information in the database.

Attributes
Attributes are the properties of entities. Attributes are represented by means of ellipses.
Every ellipse represents one attribute and is directly connected to its entity (rectangle).
If the attributes are composite, they are further divided in a tree like structure. Every node
is then connected to its attribute. That is, composite attributes are represented by ellipses
that are connected with an ellipse.
Multivalued attributes are Derived attributes are
depicted by double ellipse. depicted by dashed ellipse.
Generalization
The process of generalizing entities, where the generalized entities contain the
properties of all the generalized entities, is called generalization. In
generalization, a number of entities are brought together into one generalized
entity based on their similar characteristics. For example, pigeon, house sparrow,
crow and dove can all be generalized as Birds.
Specialization
Specialization is the opposite of generalization. In specialization, a group of entities is
divided into sub-groups based on their characteristics. Take a group ‘Person’ for example.

In a school database, persons can be specialized as teacher, student, or a staff, based on


what role they play in school as entities.
Inheritance
We use all the above features of ER-Model in order to
create classes of objects in object-oriented
programming. The details of entities are generally
hidden from the user; this process known as
abstraction.

Inheritance is an important feature of Generalization


and Specialization. It allows lower-level entities to
inherit the attributes of higher-level entities.

For example, the attributes of a Person class such as


name, age, and gender can be inherited by lower-level
entities such as Student or Teacher.
Example:
1

M
Example:
Example:

Ternary Relationship
(Degree 3)
Thank
s!
Any questions?
Just message me 

You might also like