Lecture 5

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 32

ENTITY RELATIONSHIP

MODEL
PART 1
S
STEPS IN DEVELOPING A
DATABASE

Requireme
nts
analysis

Applicatio Conceptua
ns and l Database
security design

Physical Logical
Database Database
design design

Schema
refinemen
t
S

CONCEPTUAL DESIGN

What are the entities and relationships in the enterprise?

What information about these entities and relationships


should we store in the database?

What are the integrity constraints or business rules that


hold?

A database `schema’ in the ER Model can be represented


pictorially (ER diagrams).

Can map an ER diagram into a relational schema.


WHAT IS ER MODEL? Perspective

 BU Information system
ER model is used to show the Conceptual
schema of an organisation.
 Independent of specific data model or
DBMS. Physical

ERM
Relation
data
 The model is later transformed into a Logical al Model
storage
model (e.g. relational) on which the physical Concept
database is built. Logical Physical
ual
model model
model
Notations in Entity Relationship
Diagram
ER MODEL BASICS
nam
 The basics of ER modelling e addre
ssn
 ss
Entity Employe
 Relationship e
 Attribute Works_i
n

Departme
nt D_nam
D_id
e
ENTITY AND ENTITY SET
Entity type name
(singular, no spaces,
 Entity: Real-world object distinguishable capital letter at start
from other objects. An entity is described E n tityNa m e of each word)
using a set of attributes. Each attribute has
a domain. space for attributes

 Entity Set: A collection of similar entities.


E.g., all employees.
 All entities in an entity set have the same E
set of attributes. 1
E
 Entity Set
Each entity set has a key. 2
E
3
ATTRIBUTES
Properties associated each entity with a value from a domain
of values.
 Simple attribute: Single valued attribute which can not be divided further e.g., phone.
 Composite attribute: Made of more than one simple attribute e.g., name, address etc.
 Derived attribute: Values are derived from other attributes present in the database e.g.,
age, average salary etc.
 Single-value attribute: Contains single value e.g., SSN, SID etc.
 Multivalued attribute: It may contain more than one values e.g., phone number, email_
address etc.
ATTRIBUTES CONTD.

Geometric shapes and their meaning:


 Rectangle: Represents Entity sets.
 Ellipses: Attributes
 Diamonds: Relationship Set
 Lines: They link attributes to Entity
Sets and Entity sets to Relationship Set
 Double Ellipses: Multivalued
Attributes  Entity type Student with its
 Dashed Ellipses: Derived Attributes attributes
Hospital ER
Company ER
ENTITY SET AND KEYS

 Key is an attribute or a set of attributes that uniquely


identifies an entity among entity set.

There are mainly three types of keys:


 Super key is a set of attributes that collectively
identifies an entity in an entity set.
 Candidate key is a minimal super key and an entity
set may have more than one candidate key.
 Primary key is one of the candidate keys chosen by
the database designer to uniquely identify the entity
set.
EXAMPLE
RELATIONSHIP AND RELATIONSHIP SET
 Relationship: Association among two or
more entities.
 Relationship Set: Collection of similar Enrols_i
Student Course
relationships. Same entity set could n
participate in different relationship sets,
or in different “roles” in same set.
 Ex. 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.
RELATIONSHIP: CONSTRAINTS
• binary (connects 2 entity types)
• unary/ recursive (connects 1 entity type with
degree of a itself)
relationship type • complex (connects 3 or more entity types)
• Ternary (connects 3)
• one to one (1:1)
Cardinality ratio • one to many (1:m)
• many to many (m:n)

Participation • full/mandatory
• or partial/optional
constraint
EXAMPLE:
Every employee works for
employee Worksfor
exactly one department and Department

a department can have E1 .


D1
many employees. E2
E3
.
.
D2
D3
E4 .
New department may not E5
E6
.
.
have any employee. E7 .
EXAMPLE:
Every employee works for
employee Worksfor
exactly one department and Department

a department can have E1 .


D1
many employees. E2
E3
.
.
D2
D3
E4 .
New department may not E5
E6
.
.
have any employee. E7 .

DEGREE=2
EXAMPLE:
Every employee works for
employee Worksfor
exactly one department and Department

a department can have E1 .


D1
many employees. E2
E3
.
.
D2
D3
E4 .
New department may not E5
E6
.
.
have any employee. E7 .

DEGREE=2
CARDINALITY RATIO = MAX (1,N)
PARTICIPATION/EXISTENCE = MIN
(1,0)
Works for

N 1
EXAMPLE: emp dept

N
1
Every employee works for
Worksfor
exactly one department and employee Department

a department can have E1 .


D1
many employees. E2
E3
.
.
D2
D3
E4 .
New department may not E5
E6
.
.
have any employee. E7 .

DEGREE=2
CARDINALITY RATIO = MAX (1,N)
PARTICIPATION/EXISTENCE = MIN
(1,0)
Supervis
Employe Works_I Departm
es
e n ent
Staff
Binary
Relationship
Unary or
Employe Works_I Departm
e n ent Recursive
Relationship Student
Ternary Location Welfare
Relations Project
hip Employe Works_I Departm
e n ent
Location
Project
Employe Works_I Departm P&D
Quaterna
e n ent N-ary
ry Relations
Project Complex hip
Relations
Relationship
hip
CARDINALITY AND ORDINALITY

 Cardinality specifies the number of


times an entity of an entity set
participates in a relationship.
 Ordinality specifies whether a
relationship is either mandatory or
optional.
 Cardinality specifies maximum
number of relationships and ordinality
specifies the absolute minimum
number of relationship
PARTICIPATION CONSTRAINTS

 Participation Constraint is applied on the entity participating in the


relationship set.
 It specifies the number of instances of an entity that are participating
in the relationship type.
 It is also called the minimum cardinality constraint.

There are two types of participation constraint:


 Total participation
 Partial participation
TOTAL PARTICIPATION
 Each entity present in the
entity set must mandatorily Student
enrol
Course
participate in at least one ls
relationship instance of that  It specifies that each student
relationship set must be enrolled in at least
 It is represented using a one course where the
double line between the “student” is the entity set and
entity set and relationship relationship “enrolls” signifies
set total participation
 It means that every student
must have enrolled at least in
one course
PARTIAL PARTICIPATION
 It specifies that each entity in
the entity set may or may not
participate in the relationship enrol
Student Course
ls
instance of the relationship
set, is also called as optional  A single line between the entity i.e
participation courses and enrolls a relationship
signifies the partial participation, which
 It is represented using means there might be some courses
a single line between the where enrollments are not made i.e
entity set and relationship enrollments are optional in that case
set in the ER diagram
MCQ

A recursive relationship is a relationship between an


entity and _________.

 Itself
 A subtype entity
 An instance entity
 A supertype entity
MCQ

In one to many relationship, the entity that is on the one


side of the relationship is called a(n) ________ entity.

 Parent
 Child
 Instance
 Subtype
MCQ

The number of entities to which another entity can be


associated via a relationship set is expressed as :

 Entity
 Cardinality
 Schema
 Attributes
REFERENCES

 http://www.agiledata.org/essays/dataModeling101.html
 https://www.vertabelo.com/blog/chen-erd-notation/
 https://www.guru99.com/dbms-keys.html
 http://www.mathcs.emory.edu/~cheung/Courses/377/Syllabus/2
-ER/ER-diagram.html
 https://www.studytonight.com/dbms/
 https://www.youtube.com/watch?v=QpdhBUYk7Kk
 https://www.youtube.com/watch?v=-CuY5ADwn24&t=110s
 https://www.youtube.com/watch?v=XUdNVaSikqY

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy