Database Management Systems: Entity Relationship Diagram

You might also like

Download as ppsx, pdf, or txt
Download as ppsx, pdf, or txt
You are on page 1of 66

Sreevidya B.

, Department of CSE, Amrita School of Engineering, Bengaluru

pus
ru Cam
al u
ng
Database Management Systems tha m, Be
ee
id yap
a V

r
Chapter 2
ita
Vi shw

Entity
© Relationship Diagram
Am

1
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

© Am
r ita
Vi shwa Vid
yap
eetha m, Bengal uru
Cam
pus

2
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

What is an Entity Relationship Diagram (ER Diagram) ?


• An ER diagram shows the relationship among entities & relationships. pus
Cam
l uru
• ER diagram shows the complete logical structure of nga
a database.
, Be
Components of the ER Diagram ha m
eet
ya p
This model is based on three basic concepts:
Vid
a
• Entities i shw
ta V
r i
• Attributes m
©A
• Relationships

3
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Why use ER Diagrams?
ER Diagram is allowed you to communicate with the logical structure
p s
u of the
Ca m
database to users
uru al
eng
, B
ha m what fields are going to
Provide a preview of how all your tables should connect,
eet
be on each table
ya p
Vid
wa
i sh
ER diagrams are translatable ta V relational tables which allows you to build
into
databases quickly m ri
©A
The database designer gains a better understanding of the information to be
contained in the database with the help of ER diagram

4
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

ER Diagram : Basic Skeleton


pus
ru Cam
al u
ng
, Be
ha m
eet
id yap
a V
i shw
V
rita
What is an Entity……?????
m
© A
What is Relationship…….?????

What is an
Attribute…….?????

5
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

©
Attributes

Am
r ita
Vi shwa Vid
yap
eetha m, Bengal uru
Cam
pus

Student
Entity Set

6
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Entity:
• Entity is any real world object with well defined property.
pus
Cam
l uru
n ga
• An Entity can be a thing, person, place, , Be unit, object or any
ha m
item about which the data should eetbe captured and stored in
ya p
Vid
the form of properties anda tables.
i shw
ta V
mri
A
• Entity without©properties is not an entity.

7
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Examples of Entities: us
p
ru Cam
• Person: Employee, Student, Patient gal u
Ben
m,
ha
• Place: Store, Building eet
yap
id
a V
• Object: Machine, product,i s w
h and Car
ta V
mri
A
• Event: Sale, Registration, Renewal
©

• Concept: Account, Course

8
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Entity:
pus
• Table / Table Name -----> Entity ru Cam
al u
ng
, Be
ha m
• Column -----> eet
Attributes
ya p
Vid
wa
i sh
• Connection between V
r ita tables -----> Relationship
m
©A

9
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Example

University database, we have entities : Students, Courses, and Lecturers. us


mp
• Students entity can have attributes : Rollno, Name and Sem. Ca
l uru
• Course entity can have attributes : CourseCode, CourseName ngaand Credit.
, Be
et ham
• Lecturer entity can have attributes: Id, lec_Name and Area_of_Spl
e
yap
id
V
a and Lecturers.
• They might have relationships with Courses
i shw
ta V by lecturer.)
(Student registers for a courseritaught
A m
©
(registers and taught are relationships)

10
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

© Am
r ita
Vi shwa Vid
yap
eetha m, Bengal uru
Cam
pus

11
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Example:
Two Entities: Student and College and their relationship.
pus
Student entity has attributes such as Stu_Id, Stu_Name & Stu_Addr and
College entity has attributes such as Col_ID & Col_Name. ru Cam
al u
n g
, Be
h
The relationship between Student and College is that the students study inm
a colleges.
e e t
ya p
V id
a
i shw
ta V
m ri
©A

12
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Rectangle: Represents Entity sets.

Ellipses: Attributes pus


ru Cam
al u
ng
, Be
Diamonds: Relationship Set
ha m
eet
id yap
a V
Double Ellipses: Multivalued Attributes i shw
V
r ita
© Am
Dashed Ellipses: Derived Attribute

Double Rectangles: Weak Entity Sets

13
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Lines: They link attributes to Entity Sets
& Entity sets to Relationship Set /
Partial participation of an entity in a
relationship
Double Lines: Total participation of an pus
entity in a relationship
ru Cam
al u
Cardinality:  specifies how many eng
instances of an entity relate to one 1:1 , 1:M / M:1, M:N m, B
instance of another entity. tha
p ee
id ya
a V
In some cases, entities can be self- i shw
V
linked. For example, employees can
r ita
supervise other employees.
© Am

14
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Ellipse with name underlined (dashed): Discriminator pus


ru Cam
al u
ng
, Be
Ellipse with name underlined (solid): Primary Key
ha m
eet
id yap
a V
Connected Ellipses: Composite Attribute i shw
V
r ita
© Am

15
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Attributes:
There are four types of attributes: us
p
ru Cam
al u
1. Key attribute-uniquely identifies each row inenagtable
, B
Stud(regno, name, ph. No, dob, age) etham
a pe
2. Composite attribute ----- simpleid y
a V
i shw
ta V
ri ------single valued/atomic
3. Multivalued attribute
m
© A 1 A 100
2 A 101,102
4. Derived attribute----stored

16
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
1. Key attribute:
• A key attribute can uniquely identify an entity from an entity set.
p us
ama set of students.
• For example, student roll number can uniquely identify a student ufrom
C
al ur
eng
B however the text of key
• Key attribute is represented by oval same as other attributes
,
ha m
attribute is underlined. eet
ya p
Vid
wa
i sh
ta V
mri
©A

17
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
2. Composite attribute:
• An attribute that is a combination of other attributes is known as composite attribute.
pus
am as an address is
• For example, In student entity, the student address is a compositeuattribute
C
composed of other attributes such as pin code, state, country.al ur
eng
, B
ha m
eet
ya p
Vid
wa
i sh
ta V
m ri
©A

Pin code

State

Country 18
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
3. Multivalued attribute:
• An attribute that can hold multiple values is known as multivalued attribute.
• It is represented with double ovals in an ER Diagram. pus
ru Cam
• For example – A person can have more than one phone numbers al u so the phone number
ng
attribute is multivalued. , Be
ha m
eet
ya p
Vid
wa
i sh
ta V
mri
©A

19
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
4. Derived attribute:
• A derived attribute is one whose value is dynamic and derived from
pus
another attribute. It is represented by dashed oval in an ERaDiagram.
m
ru C
l u
• For example – Person age is a derived attribute asngita changes over time
, Be
and can be derived from another attribute h(Date a m of birth).
eet
ya p
Vid
wa
i sh
ta V
m ri
©A

20
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

pus
Mapping Cardinality / Cardinality Ratio / Cardinality :
ru Cam
al u
Specifies how many instances of an entity relate to how many instance of another entity
.
ng
, Be
ha m
eet
• There are four types of Mapping Cardinalities: y a p
V id
1. One to One w a
i sh
t a V
2. One to Many m ri
© A
3. Many to One
4. Many to Many

21
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

• One to One (1 : 1):


pus
When a single instance of an entity is associated with a single Cam
ruinstance of another
al u
entity then it is called one to one relationship. ng
, Be
For example, a person has only one passport and haampassport is given to one person
eet
Person(p1,p2,p3) pass(w1,w2) y
p1-w1a p p3-w2 p2
idV
a
i shw
V
r ita
© Am
1:1
1:1

22
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

• One to One (1 : 1):


pus
ru Cam
PersonPassport 1:1 al u
ng
Person Passport 1:1 , Be
ha m
eet
id yap
a V
i shw
V
r ita
Aadhar No Name
© Am PP No
P1
A1 AAA
A2 BBB P2

A3 CCC

23
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

• One to Many ( 1: M)
pus
Cam
When a single instance of an entity is associated with more l uru than one
instances of another entity then it is called one to many nga relationship.
, Be
For example – a customer can place many orders ha m but a order cannot be
placed by many customers. eet
ya p
Cust(c1,c2) Ord(o1,o2,o3) c1:o1,o2 Vid c2:o3 1:m
a
i shw
ta V o1: C1, o2: c1, o3:c2 1 :1
r i
m
©A

24
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

• One to Many (1 : M):


pus
ru Cam
CustOrder 1:M al u
ng
Cust Order 1:1 , Be
ha m
eet
1:M
id yap
a V
i s w
hOrder No
C No Name V
r ita O1
C1 AAA
© Am O2
C2 BBB
C3 CCC O3

25
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

• Many to One ( M: 1)
When more than one instances of an entity is associated with a psingleus
am
instance of another entity then it is called many to one relationship.
C
l uru
For example – many students can study in a single collegenga but a student
cannot study in many colleges at the same time. , Be
ha m
eet
ya p
Vid
wa
i sh
ta V
m ri
©A

26
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

• Many to One ( M: 1)
pus
Cam
ru
StudColl 1:1 al u
ng
Stud Coll M:1 , Be
ha m
eet
M:1 a p
id y
S1-c1 s2-c1 s3-c3 1:1 V
a c1-s1,s2 c2-s3 c3- 1:M
i s w
hColl Code
Reg No Name V
r ita c1
S1 AAA
© Am
S2 BBB
c2
S3 CCC

c3

27
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

• Many to Many ( M: N)
When more than one instances of an entity is associated with more pus than one
am
instances of another entity then it is called many to many urelationship.
C
al ur
eng
, B
For example, a can be assigned to many projects ha m and a project can be
assigned to many students. eet
ya p
Vid
a
i shw
ta V
m ri
©A

28
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
• Many to Many ( M: N)

StudProject 1:M us
p
Stud Project M:1 ru Cam
al u
M: M / M:N ng
, Be
ha m
S1- P1,P2 S2 - P1 S3 - P2, P3 eet
id yap
a V
i s w
hPjt Code
Reg No Name V
S1 AAA r ita P1
S2 BBB © Am
S3 CCC P2

P3

29
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
• Many to Many ( M: N)

Studcourse 1:M us
p
Stud course M:1 Cam
l uru
M: M / M:N n ga
, Be
S1-DB,OOPs S2-DB S3- Oops, PR 1:M(1 stud ha m reg multiple courses)
e t
e course is reg by multiple stud)
DB-s1,s2 Oops-s1,s3 PR –S3 1:M(1 ya p
V id
w a
i shcourse
Reg No Name
ta V
S1 AAA
mri DB
S2 BBB ©A
S3 CCC OOPs

PR

30
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

pus
Participation Constraints : ru Cam
al u
Specifies if all the instances or only few of the instances of an entity are participating in a relationship.
ng
, Be
ha m
eet
• There are two types of Participation:yap
V id
1. Total Participation h w a
V i s
ri t a
m
2. Partial Participation ©A

31
Total Participation
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

A Total participation of an entity set represents that each instance in entity


must participate in the relationship
pus
For example: In the below diagram each college must have at-least Cam one
l uru
associated Student nga
, Be
ha m
eet
ya p
Vid
wa
i sh
ta V
m ri
©A

32
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Total Participation pus


Cam
uru
A Total participation of an entity set represents that each linstance in entity
must participate in the relationship nga
, Be
ha m
eet
y a p
For example: In the below diagram each Vid Passport must belong to a person,
hence total participation wa
i sh
ta V
m ri
©A

33
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Partial Participation pus


Cam
ru or none of the
A Partial participation of an entity set represents that onlylufew
instances participate in the relationship. nga
, Be
ha m
eet
ya p
For example: In the below diagram every Vid person may not have a Passport,
hence partial participation wa
i sh
ta V
m ri
©A

34
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Specialization and
Generalization:
pus
ru Cam
• Specialization and Generalization are fundamental al u
ng
, Be
concepts in database modeling that are useful for ham
eet
establishing superclass-subclass relationships.idya
p
a V
i shw
ta V
m ri
©A
• They are extended ER features

35
Specialization :
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

• Specialization is a top-down approach in which a higher-level entity


is divided into multiple specialized lower-level entities. pus
Cam
l uru
nga
• In addition to sharing the attributes of the higher-level, Be entity, these
h a m
lower-level entities have specific attributes eof et their own.
ya p
Vid
wa
• Specialization is usually used Vtoishfind subsets of an entity that has a
r ita
few different or additional
A m attributes.
©

36
Specialization :
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

pus
ru Cam
al u
ng
, Be
ha m
eet
id yap
a V
i shw
V
r ita
© Am

Person : Name, Phone, Address,


Emp:Eid, sal,
Cust :email, cid, credit
37
A, 100, AA,e1,20k,1@, null, null
• Generalization:
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Generalization
pus
• Generalization is a bottom-up approach in which multiple lower-level Cam entities are
combined to form a single higher-level entity. l uru
nga
Be
• Generalization is usually used to find common attributes
a m, among entities to form a
generalized entity. It can also be thought ofpeas eththe opposite of specialization.
id ya
• The following enhanced entity relationship
a V diagram expresses entities in a
i
hierarchical database to demonstrate shw generalization:
ta V
m ri
©A

38
Generalization :
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Cust:
Name
pus
Phone
C a m
uruAddress
l Credit
nga
Bottom –up
, Be Email
Approach
ha m cid
eet
ya p
Vid
wa Emp:
i sh Name
V
r ita Ph

© Am Address
Eid
Sal

Generalization
39
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Constraints on Generalization / Specialization:


pus
Cam
l uru
nga
• Condition based Vs User Defined , Be
ha m
eet
• Overlapping Vs Disjoint id yap
a V
i shw
V
r ita
© Am

40
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
disjoint entities
Mobile
PAN No
No

Employee pus
Cam
The lower level entities
will not have any
l uru
instances overlapping.
nga
i.e., the instance can IS A , Be
belong to only one of ha m
eet
the lower entities
ya p
a Vid
An employee can either Full Time
i shw Part Time
be a part time
r aV
Employee
it Employee
employee or full time
© Am
employee No. of
Salary
Hours

Emp: PAN_No, Mob_No,


FT:month_Sal,
PT:NoH 80-FTE 20 PTE total=100 41
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
overlapping entities Adhar Mobile
card No No

Person pus
Cam
Name

l uru
nga
IS A , Be
The lower level entities
ha m
may have overlapping eet
instances. ya p
a Vid
A teacher may be doing i s
Teacherhw Student
t a V
her part time degree in
mri
the same university
© A
Salary Eno Credits Reg No
Earned

Teachers: 30 stud: 50 teacher who is a stud: 5 =75

42
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru Exp
condition based entities
ENo Degree

Faculty Name pus


ru Cam
al u
ng
IS A , Be
ha m
eet
ya p
a Vid
The lower level i s
Lecturerhw Professor
t a V
entities are decided
mri
based on degree and A
experience No. of© No. of No. of
theory labs Research
Scholars

43
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru Name
user defined entities
RegNo Sem

Student Branch pus


ru Cam
al u
ng
IS A , Be
ha m
eet
ya p
a Vid No. of
The lower level
i sh
Executive w Secretary of events
entities have no well
ta V
members the club conducted
defined criteria mri
A
No. of ©
Exec_Id
events Sec_Id
volunteered

44
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Participation Constraints on Generalizationpus /


am
Specialization: al uru C
eng
, B
ha m
eet
• Total Participation yap
Vid
wa
• Partial Participation i sh
V
r ita
© Am

45
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Total Participation
Mobile
PAN No
No

Employee Emp = 100


pus
Cam
PT=20
All Entities from higher level
entity will participate in any of
FT =80
l u ru
the lower level entitites nga
IS A , Be
ha m
eet
ya p
a Vid
Full Time
i shw Part Time

r aV
Employee
it Employee

© Am
No. of
Salary
Hours

46
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Partial Participation
Mobile
PAN No
No
Person-30
Person Emp-10pu
s
Cam
All Entities from higher level
Cust-15
entity may not participate in any
l uru
of the lower level entities.
nga
IS A , Be
Ex: I may have details of all
ha m
people in a locality of a eet
departmental store. Some of ya p
whom may be customer of the a Vid
store, few may be employees of i s
Employeehw Customer
that store ta V
mri
© A
Order
Salary
No.

47
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Steps for constructing an ERD:


Identify the entities. The first step in making an ERD is to identify all of the entities. An entity is nothing
more than a rectangle with a description of something that your system store information p us This
about.
could be a customer, a manager, an invoice, a schedule, etc. C am
Univ has many depts. Which employ teachers and each faculty teaches courses. l u u
rSubjects are reg by
stud ng a
, Be
Identify and describe relationships. Look at two entities, are h a m related? How are the entities
they
ee t
related? Draw an action diamond between the two entitiesap on the line you just added. In the diamond
write a brief description of how they are related. id y
a V
i s w
hbetween the entities in relationship , also specify the
Cardinality: Specify the mapping cardinalities
ta V
participation constraints.
m ri
© A
Add attributes. Any key attributes of entities should be added using oval-shaped symbols.

Complete the diagram. Continue to connect the entities with lines, and adding diamonds to describe
each relationship until all relationships have been described. Each of your entities may not have any
relationships, some may have multiple relationships. That is okay.
 
48
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

pus
Cam ru
al u
ng
, Be
How to Draw a completeethER am Diagram?????
a pe
id y
a V
i shw
ta V
mri
©A

49
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Tips for Effective ER Diagrams


 
pus
• Make sure that each entity only appears once per diagram.
Cam
ru
al u
eng
• Name every entity, relationship, and attribute on your m , B
diagram.
tha
p e
eAre they necessary?
• Examine relationships between entities closely.
d ya
Vi
a
• Are there any relationships missing?
i shwEliminate any redundant relationships.
ta V
m ri
© A to each other.
• Don't connect relationships

50
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

pus
ru Cam
al u
How do we identify Entities ????? ng
, Be
ha m
eet
ya p
Vid
wa
Noun Phrase Approach
Vi sh
rita
  m
©A

51
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Case Study 1:
 In a University, there are multiple departments each of which is headed by a

pus
staff. There are multiple staffs employed in each department. There are various
m
Ca
l uru
courses offered by the department taught by teachers of the respective
nga
department. Students register for various courses.
, Be
ha m
(Assumption : Teachers teach only one course) eet
ya p
Vid
Draw the ERD wa
University (Ucode, Uname, location) i s
Xh
ta V
Department
m ri
Staff ©A
Teachers X
Course
Student

52
 In a University, there are multiple departments each of which is headed by a staff.

Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru


1 1
Cse-dr.s Dept Headed
Staff
by
ECE-dr. n
There are multiple staffs employed in each department. pus
-> 1:m ru1 m Cam
Dept
al u Has Staff
<- 1:1 n g
, Be
a
There are various courses offered by the department taught by teachers
h m
of the respective department. Adb,ip,ncp,ss
ee t
1 midya
p
Dept o
offers a V Course

i shw
ta V
r i
staff m A m o
1
Course
h © teaches
Students register for various courses. (Assumption : Teachers teach only one course)

m n
stud o
registers Course

53
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Dname

Dept Ccode
Dloc
course pus
Cnameam
u C
al ur
eng
, B Credit
ha m
eet
id yap
a V
Fname
i shw Name
Name
ta V
mri
Lname Stud
Staff
Sid © A RegNo

Ph No
Ph No
Age DoB

54
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Dname 1 has Fname


m Name
Dept
pusLname
Cam
Staff
Dloc Sid
1 1
l uru
1 Headed by
nga
, Be
ha m Ph No
offers m
ee t
teaches ya p
Vid
m a
Ccode 1
i shw Name
V
r ita
Cname Course A m registers Stud
© m n
RegNo

Credit Ph No
grade DoB
Age

55
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Course registered by stud………………….grade—registers pus


Course and stud…..r/t m:n ru Cam
al u
ng
, Be
ha m
stud entity with grade attr….. X
eet
Course entity with grade attr……X id yap
a V
i shw
ta V Reg Ccode grade
stud Reg Name iCode
r cname
m
A C1 Db 1 C1 A+
1 A © 1 C2 B
2 b c2 OS
C3 PR 2 C1 A
3 A

56
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Weak Entity, Discriminator and Identifying Relationship.


• The entity sets which do not have sufficient attributes to form a primary key are
p us
known as weak entity sets and the entity sets which have aCaprimary m key are
l uru
known as strong entity sets. nga
, Be
ha m
• t
As the weak entities do not have any primary key, they ecannot
e be identified on their own, so they
ya p
depend on some other entity (known as owner Vid strong entity). The weak entities have total 
entity/
wa
i sh
ta V
participation constraint (existenceridependency) in its identifying relationship with owner identity.
A m
© keys.
Weak entity types have partial

• Partial Keys are set of attributes with the help of which the tuples/records of the weak entities can

be distinguished and identified.


57
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

A1 B1
Strong Identifying Weak ---
Entity Relationship Entity B2 pus
A2
ru Cam
al u
eng B3
, B
ha m
eet
ya p
• Partial Key in the weak Entity is discriminator. V id
w a
• i sh is Strong Entity / Owner Entity.
Entity on which weak Entity is dependent
ta V on
r i
• To uniquely identify records in A m
a weak Entity:
©
Primary Key of the Owner Entity + Discriminator of the Weak Entity.
• Relationship between Weak Entity and Owner Entity is Identifying Relationship.

58
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

CampusCode RollNo
Relatio --- --
Campus
ship
nship
Has Stud
Name pus
Cam
CampusLoc ship

l uru
nga Sem
Roll No Name Sem , Be
CampusCode ha m
CampusLoc
01 A 5
eet
02 A 3 CBR
ya p Ettimadai
BLa V
id Bengaluru
01 B 5
i shw
V
03 C 3
r ita
© Am
Primary Key of the strong entity: Campus Code
Discriminator : Roll No
To uniquely identifying record /row of a weak entity : (CampusCode, RollNo)

59
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

CampusCode SlNo
Relatio --- --
Campus
ship
nship
Has Stud
Name pus
Cam
CampusLoc ship

l uru
nga Sem
Sl No Name Sem , Be
CampusCode ha m
CampusLoc
01 Adi 5
eet
02 A 3 CBR
ya p Ettimadai
BLa V
id Bengaluru
01 Abhi 5
i shw
V
02 C 3
r ita
© Am
Discriminator

CBR01 (campuscode,Slno)
BLR01

60
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru In a city, there are multiple univ, each of which has multiple library
•  Assume in a (Amrita) University, there are multiple libraries and each library has
many student members. A student may be a member in multiple libraries.
pus
• Each library has its own set of books. Within the library, these books aare
C m identified by
a unique number. l uru
nga
• Students can borrow multiple books from subscribed library. , Be
ha m
• Students can also borrow books through inter ee t
library loan ie., in case the book is
ya p
unavailable in his/her subscribed library, i d
V the subscribed library avails from the other
wa
i sh
a V
library in which the student is not a member.
r it
Draw the ERD A m
©
Strong Entity BRANCH Weak Entity PK? Discriminator?
Strong Entity GENRE Weak Entity ? PK? Discriminator?
Strong Entity LIBRARY Weak Entity BOOK PK LibCode Discriminator BookNo

61
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
Library : LibCode,LibLoc

L1, GndFlr
pus
L2 , FirstFlr
ru Cam
al u
ng
Book: Bno, Title
, Be
ha m
B1, DB eet
id yap
B2, OS a V
i shw
V
B1, PR r ita
© Am
B2, OS

L2,B2----- (pk of lib , Discriminator of Book)


62
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Case Study 2: pus


ru Cam
•  University X
al u
ng
• Library (LibNo, LibLoc) , Be
ha m
• Student(RegNo,Name,Sem) eet
• Books (ISBN, Title, Author, price) id yap
a V
i shw
Draw the ERD V
r ita
© Am

63
Loans
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru
book
from
1 m L1: B1, B2, B3, B4 Srini(B5)
LibNo
Library
LibLoc
L2: B1, B2, B5 ---sree(B3), raj(B4)
pus
ru Cam
al u
1 1 n g m
, Be
loans ha m Is a
has eet member
ya p
1 Vid n
bNo m wa
i sh
--- V Name
r ita
bname
Book
© Amm borrows Stud
RegNo
1

AuthorName
Ph No

64
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Case Study 3: pus


Cam
ru branches.
•  Assume in a city, there are multiple banks and each bank has many
al u
Each branch has multiple customers. eng
, B
• Customers have various types of accounts. ha m
eet
• Customers can also avail different types ya pof loans from the respective
Vid
branches. wa
i sh
ta V
ri accounts and can avail multiple loans.
• One customer can have multiple
m
© A
Draw the ERD DLB---B1, B2
SBI----B1, B2, B3

65
Sreevidya B., Department of CSE, Amrita School of Engineering, Bengaluru

Case Study 4:
• Given below are entities, connect them appropriately with necessary
pus
relationship and relationship constraints including mapping cardinalities
C am and
l uru
participation constraints.
n ga
, Be
Complete the ERD with Attributes for each entity and key
m attributes if any.
tha
pee
d ya
Vi
a
i shw
ta V
mri
©A

66

You might also like