Lecture Notes Unit 1 chapter 6 E-R MODEL

Murugan146644 1,519 views 53 slides Sep 16, 2024
Slide 1
Slide 1 of 53
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53

About This Presentation

Description:
Welcome to the comprehensive guide on Relational Database Management System (RDBMS) concepts, tailored for final year B.Sc. Computer Science students affiliated with Alagappa University. This document covers fundamental principles and advanced topics in RDBMS, offering a structured appr...


Slide Content

RDBMS -Unit I
Chapter 6
Database design and ER Model
Prepared By
Dr.S.Murugan, Associate Professor
Department of Computer Science,
AlagappaGovernmentArts College, Karaikudi.
(Affiliated by AlagappaUniversity)
Mailid: [email protected]
Reference Book:
Database System Concepts by Abraham Silberschatz, Henry
F.Korth, S. Sudharshan

6.2 The Entity-Relationship Model
➢Theentity-relationship(E-R)datamodelrepresents
theoveralllogicalstructureofadatabase.
➢TheE-Rmodelisveryusefulinmappingthe
meaningsandinteractionsofreal-worldenterprises
ontoaconceptualschema.
➢TheE-Rdatamodelemploysthreebasicnotions:
entitysets,relationshipsets,andattributes.

6.2.1 Entity Sets
➢Anentityisa"thing"or"object"intherealworldthat
isdistinguishablefromallotherobjects.
➢AsetofattributeiscalledanEntity.
➢Anentityhasasetofproperties,andthevaluesfor
somesetofpropertiesmayuniquelyidentifyanentity.
➢Forinstance,apersonmayhaveaperson-idproperty
whosevalueuniquelyidentifiesthatperson.

6.2.1 Entity Sets
➢Anentitysetisasetofentitiesofthesametypethat
sharethesameproperties,orattributes.
➢AsetofentityiscalledEntityset.
➢Forexample,thesetofallpersonswhoarecustomers
atagivenbank,canbedefinedastheentityset
customer.
➢Similarly,theentitysetloanmightrepresentthesetof
allloansawardedbyaparticularbank.

6.2.1 Entity Sets

6.2.2 Relationship Sets
➢Arelationshipisanassociationamongseveralentities.
Forexample,wecandefinearelationshipthat
associatescustomerHayeswithloanL-15.
➢Arelationshipsetisasetofrelationshipsofthesame
type.
➢Forexample,Figure6.2showstherelationshipset
borrowertodenotetheassociationbetween
customersandtheloansthatthecustomershave.

6.2.2 Relationship Sets

6.2.3 Attributes
➢Foreachattribute,thereisasetofpermittedvalues,
calledthedomain,orvalueset,ofthatattribute.
➢Thedomainofattributecustomer-namemightbethe
setofalltextstringsofacertainlength(Ex:customer-
namechar(25))

6.2.3 Attributes
➢Anattribute,asusedintheE-Rmodel,canbe
characterizedbythefollowingattributetypes.
➢Simpleandcompositeattributes:AnAttributecan
notbedividedintosubpartiscalledsimpleattribute.
AnAttributecanbedividedintosubpartiscalled
compositeattribute.
➢ExampleforSimpleattribute:Age.
➢Exampleforcompositeattribute:name.An
attributenameconsistingoffirstname,middle-
initial,andlast-name.
➢Single-valuedandmultivaluedattributes:An

6.2.3 Attributes
➢Single-valuedandmultivaluedattributes:An
attributehassinglevalueforaspecificentityiscalled
singleattribute.
➢Forex,theloan-numberattributeforaspecificloan
entityreferstoonlyoneloannumber.
➢Anattributehasmultiplevalueforaspecificentityis
calledmulti-valuedattribute.
➢Forexampleanemployeemayhavezero,one,or
severalphonenumbers.

6.2.3 Attributes
➢Derivedattribute:Thevalueforthistypeofattribute
canbederivedfromthevaluesofotherrelated
attributesiscalledderivedattribute.
➢Forexampletheageoftheemployeemaybe
calculatedfromdate-of-birthandcurrentdate.
Age=current_date–date_of_birth
➢Anattributetakesanullvaluewhenanentitydoesnot
haveavalueforit.Thenullvaluemayindicate"not
applicable"

6.2.3 Attributes

6.3 Constraints
An E-R enterprise schema may define certain constraints
to which the contents of a database must conform.

6.3.1 Mapping Cardinalities
Mappingcardinalities,orcardinalityratios,expressthenumber
ofentitiestowhichanotherentitycanbeassociatedviaa
relationshipset.

6.3.1 Mapping Cardinalities

6.3.1 Mapping Cardinalities
➢AnE-Renterpriseschemamaydefinecertain
constraintstowhichthecontentsofadatabasemust
conform.
➢ForabinaryrelationshipsetRbetweenentitysetsA
andB,themappingcardinalitymustbeoneofthe
following:
➢One-to-one:AnentityinAisassociatedwithatmost
oneentityinB,andanentityinBisassociatedwithat
mostoneentityinA.(SeeFigure6.5a.)
➢one-to-many:AnentityinAisassociatedwithany
number(zeroormore)ofentitiesinB.AnentityinB,

6.3.1 Mapping Cardinalities
canbeassociatedwithatmostoneentityinA.(See
Figure6.5b.)
➢Many-to-one:AnentityinAisassociatedwithat
mostoneentityinB.AnentityinB,however,canbe
associatedwithanynumber(zeroormore)ofentities
inA.(SeeFigure6.6a.)
➢Many-to-many:AnentityinAisassociatedwithany
number(zeroormore)ofentitiesinB,andanentityin
Bisassociatedwithanynumber(zeroormore)of
entitiesinA.(SeeFigure6.6b.)

6.3.2 Keys
➢Thevaluesoftheattributeofanentitymustbe
uniquelyidentified.
➢Inotherwords,notwoentitiesinanentitysetare
allowedtohaveexactlythesamevalueforall
attributes.

6.3.3 Participation Constraints
➢TheparticipationofanentitysetEinarelationshipset
RissaidtobetotalifeveryentityinEparticipatesin
atleastonerelationshipinR.
➢IfonlysomeentitiesinEparticipateinrelationshipsin
R,theparticipationofentitysetEinrelationshipRis
saidtobepartial.
➢Forexample,weexpecteveryloanentitytoberelated
toatleastonecustomerthroughtheborrower
relationship.Thereforetheparticipationofloaninthe
relationshipsetborroweristotal.
➢customerintheborrowerrelationshipsetisthepartial.

6.3.3 Participation Constraints

6.4 Entity-Relationship Diagrams
➢AnE-Rdiagramcanexpresstheoveralllogical
structureofadatabasegraphically.
➢E-Rdiagramsaresimpleandclear.
➢AnERdiagramconsistsofthefollowingmajor
components:
➢Rectangles,whichrepresententitysets.
➢Ellipses,whichrepresentattributes.
➢Diamonds,whichrepresentrelationshipsets.

6.4 Entity-Relationship Diagrams
➢Lines,whichlinkattributestoentitysetsandentity
setstorelationshipsets.
➢Doubleellipses,whichrepresentmultivalued
attributes.
➢Dashedellipses,whichdenotederivedattributes.
➢Doublelines,whichindicatetotalparticipationofan
entityinarelationshipset.
➢Doublerectangles,whichrepresentweakentitysets.

6.4 Entity-Relationship Diagrams
AnE-Rdiagramcanexpresstheoveralllogicalstructure
ofadatabasegraphically.
E-Rdiagramsaresimpleandclear.
AnERdiagramconsistsofthefollowingmajor
components:
Rectangles,whichrepresententitysets.
Ellipses,whichrepresentattributes.
Diamonds,whichrepresentrelationshipsets.
Lines,whichlinkattributestoentitysetsandentitysetsto

6.2.3 Attributes

6.4 Entity-Relationship Diagrams
➢Considertheentity-relationshipdiagraminFigure6.7,
whichconsistsoftwoentitysets,customerandloan,
relatedthroughabinaryrelationshipsetborrower.
➢Theattributesassociatedwithcustomerarecustomer-
id,customer-name,customer-street,andcustomer-city.
Theattributesassociatedwithloanareloan-number
andamount.
➢Therelationshipsetborrowermaybemany-to-many
(Fig.6.7),one-to-many(Fig.6.8a),many-to-one
(Fig.6.8b),orone-to-one(Fig.6.8c).
➢Todistinguishamongthesetypes,wedraweithera
directedline(→)oranundirectedline()between
therelationshipsetandtheentityset.

6.4 Entity-Relationship Diagrams
Figure 6.7 shows many-many relationship

6.4 Entity-Relationship Diagrams

6.4 Entity-Relationship Diagrams

6.4 Entity-Relationship Diagrams
➢InFigure6.9,theaccessdateattributeattachedtothe
relationshipsetdepositortospecifythemostrecent
dateonwhichacustomeraccessedthataccount.

6.4 Entity-Relationship Diagrams

6.4 Entity-Relationship Diagrams
Figure6.11showstheroleindicatorsmanngerand
workerbetweentheemployeeentitysetandthe
works_forrelationshipset.

6.4 Entity-Relationship Diagrams
➢Figure6.12consistsofthethreeentitysetsemployee,
job,andbranch,relatedthroughtherelationshipset
works-on.

6.4 Entity-Relationship Diagrams
➢Adoublelinefromloantoborrower,asinFigure
6.13,indicatesthateachloanmusthaveatleastone
associatedcustomer.

6.5 Entity-Relationship Design lssues
6.5.1 Use of Entity Sets versus Attributes
➢Choicemainlydependsonthestructureofthe
enterprisebeingmodeled,andonthesemantics
associatedwiththeattributeinquestion.
➢Considertheentitysetemployeewithattributes
employee_id,employee-nameandtelephone-number.
➢Intheabovestructurethetelephonenumbermaybe
zerooroneormorethanone.
➢ThealternativedesignmaybeTheemployeeentity
setwithattributesemployee-idandemployee_name.
➢Thetelephoneentitysetwithattributes
telephonenumberandlocation

6.5 Entity-Relationship Design lssues
6.5.1 Use of Entity Sets versus Attributes

6.5.2 Use of Entity Sets versus Relationship Sets
➢Possibleguidelineistodesignatearelationshipsetto
describeanactionthatoccursbetweenentities.
➢InFig6.16,Eachloanisrepresentedbya
relationshipbetweenacustomerandabranch.
➢Ifeveryloanisheldbyexactlyonecustomerandis
associatedwithexactlyonebranch.
➢Withthisdesign,wecannotrepresentconvenientlya
situationinwhichseveralcustomersholdaloan
jointly.
➢Tohandlesuchasituation,wemustdefineaseparate
relationshipforeachholderofthejointloan.

6.5.2 Use of Entity Sets versus Relationship Sets

6.5.3 Binary versus n-aryRelationship Sets
➢Relationshipsindatabasesareoftenbinary.
➢itisalwayspossibletoreplaceanon-binary(n-ary,for
n>2)relationshipsetbyanumberofdistinctbinary
relationshipsets.
➢Forsimplicity,considertheabstractternary(n=3)
relationshipsetR,relatingentitysetsA,B,and,c.
➢wereplacetherelationshipsetRbyanentitysetE,and
createthreerelationshipsetsasshowninFigure6.17:
➢RA,relatingEandA
➢RB,relatingEandB
➢Rc,reiatingEandC

6.5.3 Binary versus n-aryRelationship Sets

6.5.4 Placement of Relationship Attributes
➢Canmakeaccess-dateanattributeofaccount,instead
ofarelationshipattribute,ifeachaccountcanhave
onlyonecustomer
➢Thatis,therelationshipfromaccounttocustomeris
manytoone,orequivalently,customertoaccountis
onetomany

6.6 Weak Entity Sets
➢Anentitysetthatdoesnothasaprimarykeyis
termedaweakentityset.
➢Anentitysetthathasaprimarykeyistermeda
strongentityset.
➢Sequencenumberisthepaymentnumber.payments
fordifferentloansmaysharethesamepayment
number.
➢Foraweakentitysettobemeaningful,itmustbe
associatedwithanotherentityset,calledthe
identifyingorownerentityset.

6.6 Weak Entity Sets

6.7 Extended E-R Features
➢ExtendedE-Rfeaturesofspecialization,
generalization,higher-andlower-levelentitysets,
attributeinheritanceandaggregation.

6.7.1 Specialization
➢Anentitysetmayincludesubgroupingsofentitiesthat
aredistinctinsomewayfromotherentitiesintheset.
➢Asanexample,consideranentitysetpersonwith
attributesperson-id,name,street,andcity.Apersonmay
befurtherclassifiedascustomerandemployee.
➢Eachofthesepersontypesisdescribedbyasetof
attributesthatincludesalltheattributesofentityset
personpluspossiblyadditionalattributes.
➢Forexamplecustomerentrtiesmaybedescribedfurther
byanattributecreditrating,whereasemployeeentities
maybedescribedfurtherbytheattributesalary.

6.7.1 Specialization

6.7.2 Generalization
➢Representationofmorethanoneentitysetwith
commonattributeiscalledgeneralization.
➢Therearesimilaritiesbetweenthecustomerentityset
andtheemployeeentityset.
➢Theyhaveseveralattributesarecommoninthetwo
entitysets:namely,theidentifier,name,street,and
cityattributes.
➢Thiscommonalitycanbeexpressedby
generalization.

6.7.3 Attribute lnheritance
➢Thehigher-andlower-levelentitiescreatedby
specializationandgeneralizationisattribute
inheritance.Figure6.20depictsahierarchyofentity
sets.
➢Theattributesofthehigher-levelentitysetsiresaid
tobeinheritedbythelower-levelentitysets.
➢Forexample,customerandemployeeinheritthe
attributesofperson.
S.No.Higher Level Entity SetLower LevelEntity Set
1. Person Customer, Employee
2. Employee Officer, Teller, Secretary

Specialization & Generalization

6.7.4 Constraints on Generalizations
➢Thelowerlevelentitysetmaybeconditiondefined
orDisjoint.
➢Inconditiondefined,theconditionmaybedefined
fortheparticularattribute.
➢Forexample,Theaccountentitysethastheattribute
account_typeanditcontainsthevalueeither“saving”
or“Checking”account.
➢Indisjoint,Anentitycansatisfyonlyonecondition.
➢Forexample,Theaccountentitysethastheattribute
account_typeanditcontainsthevalueeither“saving”
or“Checking”accountbutcannotbeboth.

6.7.4 Constraints on Generalizations
➢Thecompletenessconstraintmaybeoneofthe
following.
➢Totalgeneralizationorspecialization:Eachhigher-
levelentitysetmustbelongtoalower-Ievelentity
set.[Ex:Employeehasofficer,tellerandsecretary]
➢Partialgeneralizationorspecialization:Some
higher-levelentitysetmaynotbelongtoanylower-
levelentityset.[Ex:Customerdon’thaveanylower
levelentityset]

6.7.5 Aggregation
➢OnelimitationoftheE-Rmodelisthatitcannot
expresstherelationshipsamongrelationships.
➢Forexample,themanagermanagestheemployee
workedinvariousbranches.Wecannotrepresentthe
ERdiagramlikethis[Fig6.12&Fig.6.21].
➢Becauseitcontainsrelationshipredundancy.

6.7.5 Aggregation

6.7.5 Aggregation
➢Theaboveproblemissolvedbyaggregation.The
Aggregationisanabstractionthroughwhich
relationshipsaretreatedashigherlevelentities.
➢InFig.6.22,createabinaryrelationshipmanages
betweenworks-onandmanagertorepresentwho
manageswhattasks.