One to One Relationship
•Init,foreachinstanceinEntityclassA,thereisonlyoneinstanceinEntity
classBandforeachinstanceinEntityclassB,thereisonlyoneinstancein
EntityclassA.
University VC
eId
eName
uName
ud uAddr
Country Presidenthas
pId
pName
cName
cId Area
has
One to Many Relationship
•Init,foreachinstanceinEntityclassA,therearemanyinstancesinEntity
classBandforeachinstanceinEntityclassB,thereisonlyoneinstancein
EntityclassA.
Country Cityhas
cityId
cityName
cName
cId Area
University Department
dId
dName
uName
ud uAddr
has
Many to Many Relationship
•Init,foreachinstanceinEntityclassA,therearemanyinstancesinEntity
classBandforeachinstanceinEntityclassB,therearemanyinstancesin
EntityclassA.
Student Course
cCode
cName
sName
sId sPhone
Author Bookwrite
bID
bName
aName
aId aPhone
Registers
Types of Cardinalities
DEPT
Chair
Person
One to one
EMPDEPT
One to many
PROJEMP
Many to many
Examples of Relationships and their cardinalities
•Example1
•PATIENTHasRecordedPATIENTHISTORY:Eachpatienthasoneormorepatient
histories.(TheinitialpatientvisitisalwaysrecordedasaninstanceofPATIENTHISTORY.)Each
instanceofPATIENTHISTORY“belongsto”exactlyonePATIENT.
Examples of Relationships and their cardinalities
•Example2
•EMPLOYEE IsAssignedToPROJECT:EachPROJECThasatleastoneEMPLOYEE
assignedtoit.(Someprojectshavemorethanone.)EachEMPLOYEEmayormaynotbe
assignedtoanyPROJECTormaybeassignedtooneormorePROJECTs.
Examples of Relationships and their cardinalities
•Example3
•STUDENTIsBorrowedBook:Astudentmayormaynotborrowabookfromlibraryandmay
borrowmanybooks.Abookmustbeborrowedbyonlyonestudentatatimeandabookmaynot
beborrowedbyanystudent
Student Borrow Book
Optional Optional