最新数据库系统基础教程第五章答案.docx
《最新数据库系统基础教程第五章答案.docx》由会员分享,可在线阅读,更多相关《最新数据库系统基础教程第五章答案.docx(21页珍藏版)》请在冰豆网上搜索。
最新数据库系统基础教程第五章答案
Exercise5.1.1
Asaset:
speed
2.66
2.10
1.42
2.80
3.20
2.20
2.00
1.86
3.06
Average=2.37
Asabag:
speed
2.66
2.10
1.42
2.80
3.20
3.20
2.20
2.20
2.00
2.80
1.86
2.80
3.06
Average=2.48
Exercise5.1.2
Asaset:
hd
250
80
320
200
300
160
Average=218
Asabag:
hd
250
250
80
250
250
320
200
250
250
300
160
160
80
Average=215
Exercise5.1.3a
Asaset:
bore
15
16
14
18
Asabag:
bore
15
16
14
16
15
15
14
18
Exercise5.1.3b
πbore(Ships
Classes)
Exercise5.1.4a
Forbags:
Ontheleft-handside:
GivenbagsRandSwhereatupletappearsnandmtimesrespectively,theunionofbagsRandSwillhavetupletappearn+mtimes.ThefurtherunionofbagTwiththetupletappearingotimeswillhavetupletappearn+m+otimesinthefinalresult.
Ontheright-handside:
GivenbagsSandTwhereatupletappearsmandotimesrespectively,theunionofbagsRandSwillhavetupletappearm+otimes.ThefurtherunionofbagRwiththetupletappearingntimeswillhavetupletappearm+o+ntimesinthefinalresult.
Forsets:
Thisisasimilarcasewhendealingwithbagsexceptthetupletcanonlyappearatmostonceineachset.Thetupletonlyappearsintheresultifallthesetshavethetuplet.Otherwise,thetupletwillnotappearintheresult.Sincewecannothaveduplicates,theresultonlyhasatmostonecopyofthetuplet.
Exercise5.1.4b
Forbags:
Ontheleft-handside:
GivenbagsRandSwhereatupletappearsnandmtimesrespectively,theintersectionofbagsRandSwillhavetupletappearmin(n,m)times.ThefurtherintersectionofbagTwiththetupletappearingotimeswillproducetupletmin(o,min(n,m))timesinthefinalresult.
Ontheright-handside:
GivenbagsSandTwhereatupletappearsmandotimesrespectively,theintersectionofbagsRandSwillhavetupletappearmin(m,o)times.ThefurtherintersectionofbagRwiththetupletappearingntimeswillproducetupletmin(n,min(m,o))timesinthefinalresult.
TheintersectionofbagsR,SandTwillyieldaresultwheretupletappearsmin(n,m,o)times.
Forsets:
Thisisasimilarcasewhendealingwithbagsexceptthetupletcanonlyappearatmostonceineachset.Thetupletonlyappearsintheresultifallthesetshavethetuplet.Otherwise,thetupletwillnotappearintheresult.
Exercise5.1.4c
Forbags:
Ontheleft-handside:
GiventhattuplerinR,whichappearsmtimes,cansuccessfullyjoinwithtuplesinS,whichappearsntimes,weexpecttheresulttocontainmncopies.AlsogiventhattupletinT,whichappearsotimes,cansuccessfullyjoinwiththejoinedtuplesofrands,weexpectthefinalresulttohavemnocopies.
Ontheright-handside:
GiventhattuplesinS,whichappearsntimes,cansuccessfullyjoinwithtupletinT,whichappearsotimes,weexpecttheresulttocontainnocopies.AlsogiventhattuplerinR,whichappearsmtimes,cansuccessfullyjoinwiththejoinedtuplesofsandt,weexpectthefinalresulttohavenomcopies.
Theorderinwhichweperformthenaturaljoindoesnotmatterforbags.
Forsets:
Thisisasimilarcasewhendealingwithbagsexceptthejoinedtuplescanonlyappearatmostonceineachresult.Iftherearetuplesr,s,tinrelationsR,S,Tthatcansuccessfullyjoin,thentheresultwillcontainatuplewiththeschemaoftheirjoinedattributes.
Exercise5.1.4d
Forbags:
SupposeatupletoccursnandmtimesinbagsRandSrespectively.IntheunionofthesetwobagsR⋃S,tupletwouldappearn+mtimes.Likewise,intheunionofthesetwobagsS⋃R,tupletwouldappearm+ntimes.Bothsidesoftherelationyieldthesameresult.
Forsets:
Atupletcanonlyappearatmostonetime.TupletmightappeareachinsetsRandSoneorzerotimes.ThecombinationsofnumberofoccurrencesfortupletinRandSrespectivelyare(0,0),(0,1),(1,0),and(1,1).OnlywhentupletappearsinbothsetsRandSwilltheunionR⋃Shavethetuplet.ThesamereasoningholdswhenwetaketheunionS⋃R.
Thereforethecommutativelawforunionholds.
Exercise5.1.4e
Forbags:
SupposeatupletoccursnandmtimesinbagsRandSrespectively.IntheintersectionofthesetwobagsR∩S,tupletwouldappearmin(n,m)times.LikewiseintheintersectionofthesetwobagsS∩R,tupletwouldappearmin(m,n)times.Bothsidesoftherelationyieldthesameresult.
Forsets:
Atupletcanonlyappearatmostonetime.TupletmightappeareachinsetsRandSoneorzerotimes.ThecombinationsofnumberofoccurrencesfortupletinRandSrespectivelyare(0,0),(0,1),(1,0),and(1,1).OnlywhentupletappearsinatleastoneofthesetsRandSwilltheintersectionR∩Shavethetuplet.ThesamereasoningholdswhenwetaketheintersectionS∩R.
Thereforethecommutativelawforintersectionholds.
Exercise5.1.4f
Forbags:
SupposeatupletoccursntimesinbagRandtupleuoccursmtimesinbagS.Supposealsothatthetwotuplest,ucansuccessfullyjoin.TheninthenaturaljoinofthesetwobagsR
S,thejoinedtuplewouldappearnmtimes.LikewiseinthenaturaljoinofthesetwobagsS
R,thejoinedtuplewouldappearmntimes.Bothsidesoftherelationyieldthesameresult.
Forsets:
Anarbitrarytupletcanonlyappearatmostonetimeinanyset.Tuplesu,vmightappearrespectivelyinsetsRandSoneorzerotimes.Thecombinationsofnumberofoccurrencesfortuplesu,vinRandSrespectivelyare(0,0),(0,1),(1,0),and(1,1).OnlywhentupleuexistsinRandtuplevexistsinSwillthenaturaljoinR
Shavethejoinedtuple.ThesamereasoningholdswhenwetakethenaturaljoinS
R.
Thereforethecommutativelawfornaturaljoinholds.
Exercise5.1.4g
Forbags:
SupposetupletappearsmtimesinRandntimesinS.IfwetaketheunionofRandSfirst,wewillgetarelationwheretupletappearsm+ntimes.TakingtheprojectionofalistofattributesLwillyieldaresultingrelationwheretheprojectedattributesfromtupletappearm+ntimes.IfwetaketheprojectionoftheattributesinlistLfirst,thentheprojectedattributesfromtupletwouldappearmtimesfromRandntimesfromS.Theunionoftheseresultingrelationswouldhavetheprojectedattributesoftupletappearm+ntimes.
Forsets:
Anarbitrarytupletcanonlyappearatmostonetimeinanyset.TupletmightappearinsetsRandSoneorzerotimes.ThecombinationsofnumberofoccurrencesfortupletinRandSrespectivelyare(0,0),(0,1),(1,0),and(1,1).OnlywhentupletexistsinRorS(orbothRandS)willtheprojectedattributesoftupletappearintheresult.
Thereforethelawholds.
Exercise5.1.4h
Forbags:
SupposetupletappearsutimesinR,vtimesinSandwtimesinT.Onthelefthandside,theintersectionofSandTwouldproducearesultwheretupletwouldappearmin(v,w)times.WiththeadditionoftheunionofR,theoverallresultwouldhaveu+min(v,w)copiesoftuplet.Ontherighthandside,wewouldgetaresultofmin(u+v,u+w)copiesoftuplet.Theexpressionsonboththeleftandrightsidesareequivalent.
Forsets:
Anarbitrarytupletcanonlyappearatmostonetimeinanyset.TupletmightappearinsetsR,SandToneorzerotimes.ThecombinationsofnumberofoccurrencesfortupletinR,SandTrespectivelyare(0,0,0),(0,0,1),(0,1,0),(0,1,1),(1,0,0),(1,0,1),(1,1,0)and(1,1,1).OnlywhentupletappearsinRorinbothSandTwilltheresulthavetuplet.
Thereforethedistributivelawofunionoverintersectionholds.
Exercise5.1.4i
SupposethatinrelationR,utuplessatisfyconditionCandvtuplessatisfyconditionD.SupposealsothatwtuplessatisfybothconditionsCandDwherew≤min(v,w).Thenthelefthandsidewillreturnthosewtuples.Ontherighthandside,σC(R)producesutuplesandσD(R)producesvtuples.However,weknowtheintersectionwillproducethesamewtuplesintheresult.
Whenconsideringbagsandsets,theonlydifferenceisbagsallowduplicatetupleswhilesetsonlyallowonecopyofthetuple.Theexampleaboveappliestobothcases.
Thereforethelawholds.
Exercise5.1.5a
Forsets,anarbitrarytupletappearsonthelefthandsideifitappearsinbothR,SandnotinT.Thesameistruefortherighthandside.
Asanexampleforbags,supposethattupletappearsonetimeeachinbothR,TandtwotimesinS.Theresultofthelefthandsidewouldhavezerocopiesoftupletwhiletherighthandsidewouldhaveonecopyoftuplet.
Thereforethelawholdsforsetsbutnotforbags.
Exercise5.1.5b
Forsets,anarbitrarytupletappearsonthelefthandsideifitappearsinRandeitherSorT.ThisisequivalenttosayingtupletonlyappearswhenitisinatleastRandSorinRandT.Theequivalenceisexactlytherightside’sexpression.
Asanexampleforbags,supposethattupletappearsonetimeinRandtwotimeseachinSandT.Thenthelefthandsidewouldhaveonecopyoftupletintheresultwhiletherighthandsidewouldhavetwocopiesoftuplet.
Thereforethelawholdsforsetsbutnotforbags.
Exercise5.1.5c
Forsets,anarbitrarytupletappearsonthelefthandsideifitsatisfiesconditionC,conditionDorbothconditionCandD.Ontherighthandside,σC(R)selectsthosetuplesthatsatisfyconditionCwhileσD(R)selectsthosetuplesthatsatisfyconditionD.However,theunionoperatorwilleliminateduplicatetuples,namelythosetuplesthatsatisfybothconditionCandD.Thusweareensuredthatbothsidesareequivalent.
Asanexampleforbags,weonlyneedtolookattheunionoperator.IfthereareindeedtuplesthatsatisfybothconditionsCandD,