6.Entity Relationship Diagram
6.Entity Relationship Diagram
Design
Phases
User
Requiremen
ts
Specificatio Conceptual-
n design Phase
[ER Diagram] Logical-design
[Phase Relational
Schema]
Physical-
design Phase
[Relational
Database]
3
▸ Entity Set: An entity set is a set of entities of the same type that share the same properties or attributes.
▸ Attributes: Attributes are descriptive properties of the entities in the entity set. Each entity has its own
value for each attribute.
Entity
Relation:
Borrower Entity Set
Relationship Set
6
city
zipCode
street
teach
teacher
1
3
E-R Diagram >>
Example
1
4
E-R Diagram >> Relationship
Sets
Non-Identifying Relationship Set – A relationship where child
entity can exisits without parent entity, and primary key of
child doesn’t contain primary key component of parent entity.
RelSet
Located
Book Branch
at
1
4
E-R Diagram >> Relationship
Sets
Identifying Relationship Example
Entities:
1.Book:
Attributes: book_id (Primary Key), title.
2.BorrowedCopy:
1. Attributes: copy_id (Partial Key), borrow_date, book_id (Foreign Key).
Relationship:
Each borrowed copy is uniquely identified by its copy_id and the book_id it belongs to. If the
book is deleted, the borrowed copy record cannot exist.
Primary Key:
•BorrowedCopy’s primary key is a composite key: (book_id, copy_id).
ERD Representation:
•Relationship: Borrowed (double-lined diamond between Book and BorrowedCopy).
Located Borrowed
Book Borrowed
at Copy
1
4
E-R Diagram >> Relationship
Sets
Weak Entity
Identifying
relationship
Not
Identifying
1
5
E-R Diagram >> Relationship
Sets
Recursive Relationship Set – The same
entity set participates more than once in
the relationship.
TA
1
6
E-R Diagram >> Mapping
Cardinalities
Mapping cardinalities, or Cardinality ratios, express the number of entities to which another entity can be
associated via a relationship set.
One-to-one(1:1) – An entity in A is
associated with at most one entity in B,
and an entity in B is associated with at
most one entity in A.
chair-
chairperson department
dept
1
7
E-R Diagram >> Mapping
Cardinalities
One-to-many (1:N) – An entity in A is
associated with any number of entities in
B. An entity in B, however, can be
associated with at most one entity in A.
faculty
faculty class
-class
1
7
E-R Diagram >> Mapping
Cardinalities
Many-to-One (M:1) – An entity in A is
associated with any number of entities in
B. An entity in B, however, can be
associated with at most one entity in A.
1
8
E-R Diagram >> Mapping
Cardinalities
Many-to-many (M:N) – An entity in A is
associated with any number of entities in
B, and an entity in B is associated with
any number of entities in A.
Works on
Design an ER Diagram for the scenario that satisfies all the given requirements.
2
9
E-R Diagram >> Practice 7 (Job Portal
System)
Consider the following scenario for a Job portal:
▸ The job portal manages each user’s profile where each user is represented by his or her name, unique
email, address, date of birth, educational qualifications, job position and job experience. Both recruiters
and job seekers are user and one recruiter can recruit more than one job seeker.
▸ The recruiters can post job openings to the job portal. The job portal keeps track of each posts date,
time, contents,
no of viewers. The system also keeps track of which job seeker is interested in which job posts.
▸ Each of the offices is maintained by their unique office id, name, address and contact no. Every user
belongs to some offices as a recruiter or, an employee or, a follower. Each person can provide his or
her anonymous review of offices. Each of the review contains review id, date, time, review details. The
review id cannot uniquely identify a particular review but a review id together with an office id can
uniquely identify a particular review.
Design and ER Diagram for the scenario that satisfies all the given requirements.