数据库系统基础教程答案.docx

上传人:b****1 文档编号:2674502 上传时间:2023-05-04 格式:DOCX 页数:34 大小:28.14KB
下载 相关 举报
数据库系统基础教程答案.docx_第1页
第1页 / 共34页
数据库系统基础教程答案.docx_第2页
第2页 / 共34页
数据库系统基础教程答案.docx_第3页
第3页 / 共34页
数据库系统基础教程答案.docx_第4页
第4页 / 共34页
数据库系统基础教程答案.docx_第5页
第5页 / 共34页
数据库系统基础教程答案.docx_第6页
第6页 / 共34页
数据库系统基础教程答案.docx_第7页
第7页 / 共34页
数据库系统基础教程答案.docx_第8页
第8页 / 共34页
数据库系统基础教程答案.docx_第9页
第9页 / 共34页
数据库系统基础教程答案.docx_第10页
第10页 / 共34页
数据库系统基础教程答案.docx_第11页
第11页 / 共34页
数据库系统基础教程答案.docx_第12页
第12页 / 共34页
数据库系统基础教程答案.docx_第13页
第13页 / 共34页
数据库系统基础教程答案.docx_第14页
第14页 / 共34页
数据库系统基础教程答案.docx_第15页
第15页 / 共34页
数据库系统基础教程答案.docx_第16页
第16页 / 共34页
数据库系统基础教程答案.docx_第17页
第17页 / 共34页
数据库系统基础教程答案.docx_第18页
第18页 / 共34页
数据库系统基础教程答案.docx_第19页
第19页 / 共34页
数据库系统基础教程答案.docx_第20页
第20页 / 共34页
亲,该文档总共34页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

数据库系统基础教程答案.docx

《数据库系统基础教程答案.docx》由会员分享,可在线阅读,更多相关《数据库系统基础教程答案.docx(34页珍藏版)》请在冰点文库上搜索。

数据库系统基础教程答案.docx

数据库系统基础教程答案

Thefollowingtextisamendedon12November2020.

 

数据库系统基础教程答案

Exerciseforthisexercisemayvarybecauseofdifferentinterpretations.

SomepossibleFDs:

SocialSecuritynumbername

Areacodestate

Streetaddress,city,statezipcode

Possiblekeys:

{SocialSecuritynumber,streetaddress,city,state,areacode,phonenumber}

Needstreetaddress,city,statetouniquelydeterminelocation.Apersoncouldhavemultipleaddresses.Thesameistrueforphones.Thesedays,apersoncouldhavealandlineandacellularphone

Exerciseforthisexercisemayvarybecauseofdifferentinterpretations

SomepossibleFDs:

IDx-position,y-position,z-position

IDx-velocity,y-velocity,z-velocity

x-position,y-position,z-positionID

Possiblekeys:

{ID}

{x-position,y-position,z-position}

Thereasonwhythepositionswouldbeakeyisnotwomoleculescanoccupythesamepoint.

ThesuperkeysareanysubsetthatcontainsA1.Thus,thereare2(n-1)suchsubsets,sinceeachofthen-1attributesA2throughAnmayindependentlybechoseninorout.

ThesuperkeysareanysubsetthatcontainsA1orA2.Thereare2(n-1)suchsubsetswhenconsideringA1andthen-1attributesA2throughAn.Thereare2(n-2)suchsubsetswhenconsideringA2andthen-2attributesA3throughAn.WedonotcountA1inthesesubsetsbecausetheyarealreadycountedinthefirstgroupofsubsets.Thetotalnumberofsubsetsis2(n-1)+2(n-2).

Thesuperkeysareanysubsetthatcontains{A1,A2}or{A3,A4}.Thereare2(n-2)suchsubsetswhenconsidering{A1,A2}andthen-2attributesA3throughAn.Thereare2(n-2)–2(n-4)suchsubsetswhenconsidering{A3,A4}andattributesA5throughAnalongwiththeindividualattributesA1andA2.Wegetthe2(n-4)termbecausewehavetodiscardthesubsetsthatcontainthekey{A1,A2}toavoiddoublecounting.Thetotalnumberofsubsetsis2(n-2)+2(n-2)–2(n-4).

Thesuperkeysareanysubsetthatcontains{A1,A2}or{A1,A3}.Thereare2(n-2)suchsubsetswhenconsidering{A1,A2}andthen-2attributesA3throughAn.Thereare2(n-3)suchsubsetswhenconsidering{A1,A3}andthen-3attributesA4throughAnWedonotcountA2inthesesubsetsbecausetheyarealreadycountedinthefirstgroupofsubsets.Thetotalnumberofsubsetsis2(n-2)+2(n-3).

Wecouldtryinferencerulestodeducenewdependenciesuntilwearesatisfiedwehavethemall.Amoresystematicwayistoconsidertheclosuresofall15nonemptysetsofattributes.

Forthesingleattributeswehave{A}+=A,{B}+=B,{C}+=ACD,and{D}+=AD.Thus,theonlynewdependencywegetwithasingleattributeontheleftisCA.

Nowconsiderpairsofattributes:

{AB}+=ABCD,sowegetnewdependencyABD.{AC}+=ACD,andACDisnontrivial.{AD}+=AD,sonothingnew.{BC}+=ABCD,sowegetBCA,andBCD.{BD}+=ABCD,givingusBDAandBDC.{CD}+=ACD,givingCDA.

Forthetriplesofattributes,{ACD}+=ACD,buttheclosuresoftheothersetsareeachABCD.Thus,wegetnewdependenciesABCD,ABDC,andBCDA.

Since{ABCD}+=ABCD,wegetnonewdependencies.

Thecollectionof11newdependenciesmentionedaboveare:

CA,ABD,ACD,BCA,BCD,BDA,BDC,CDA,ABCD,ABDC,andBCDA.

Fromtheanalysisofclosuresabove,wefindthatAB,BC,andBDarekeys.AllothersetseitherdonothaveABCDastheclosureorcontainoneofthesethreesets.

Thesuperkeysareallthosethatcontainoneofthosethreekeys.Thatis,asuperkeythatisnotakeymustcontainBandmorethanoneofA,C,andD.Thus,the(proper)superkeysareABC,ABD,BCD,andABCD.

i)Forthesingleattributeswehave{A}+=ABCD,{B}+=BCD,{C}+=C,and{D}+=D.Thus,thenewdependenciesareACandAD.

Nowconsiderpairsofattributes:

{AB}+=ABCD,{AC}+=ABCD,{AD}+=ABCD,{BC}+=BCD,{BD}+=BCD,{CD}+=CD.ThusthenewdependenciesareABC,ABD,ACB,ACD,ADB,ADC,BCDandBDC.

Forthetriplesofattributes,{BCD}+=BCD,buttheclosuresoftheothersetsareeachABCD.Thus,wegetnewdependenciesABCD,ABDC,andACDB.

Since{ABCD}+=ABCD,wegetnonewdependencies.

Thecollectionof13newdependenciesmentionedaboveare:

AC,AD,ABC,ABD,ACB,ACD,ADB,ADC,BCD,BDC,ABCD,ABDCandACDB.

ii)Forthesingleattributeswehave{A}+=A,{B}+=B,{C}+=C,and{D}+=D.Thus,therearenonewdependencies.

Nowconsiderpairsofattributes:

{AB}+=ABCD,{AC}+=AC,{AD}+=ABCD,{BC}+=ABCD,{BD}+=BD,{CD}+=ABCD.ThusthenewdependenciesareABD,ADC,BCAandCDB.

Forthetriplesofattributes,alltheclosuresofthesetsareeachABCD.Thus,wegetnewdependenciesABCD,ABDC,ACDBandBCDA.

Since{ABCD}+=ABCD,wegetnonewdependencies.

Thecollectionof8newdependenciesmentionedaboveare:

ABD,ADC,BCA,CDB,ABCD,ABDC,ACDBandBCDA.

iii)Forthesingleattributeswehave{A}+=ABCD,{B}+=ABCD,{C}+=ABCD,and{D}+=ABCD.Thus,thenewdependenciesareAC,AD,BD,BA,CA,CB,DBandDC.

Sinceallthesingleattributes’closuresareABCD,anysupersetofthesingleattributeswillalsoleadtoaclosureofABCD.Knowingthis,wecanenumeratetherestofthenewdependencies.

Thecollectionof24newdependenciesmentionedaboveare:

AC,AD,BD,BA,CA,CB,DB,DC,ABC,ABD,ACB,ACD,ADB,ADC,BCA,BCD,BDA,BDC,CDA,CDB,ABCD,ABDC,ACDBandBCDA.

SinceA1A2…AnCcontainsA1A2…An,thentheclosureofA1A2…AnCcontainsB.ThusitfollowsthatA1A2…AnCB.

1A2…AnCB.Usingtheconceptoftrivialdependencies,wecanshowthatA1A2…AnCC.ThusA1A2…AnCBC.

FromA1A2…AnE1E2…Ej,weknowthattheclosurecontainsB1B2…BmbecauseoftheFDA1A2…AnB1B2…Bm.TheB1B2…BmandtheE1E2…EjcombinetoformtheC1C2…Ck.ThustheclosureofA1A2…AnE1E2…EjcontainsDaswell.Thus,A1A2…AnE1E2…EjD.

FromA1A2…AnC1C2…Ck,weknowthattheclosurecontainsB1B2…BmbecauseoftheFDA1A2…AnB1B2…Bm.TheC1C2…CkalsotellusthattheclosureofA1A2…AnC1C2…CkcontainsD1D2…Dj.Thus,A1A2…AnC1C2…CkB1B2…BkD1D2…Dj.

IfattributeArepresentedSocialSecurityNumberandBrepresentedaperson’sname,thenwewouldassumeABbutBAwouldnotbevalidbecausetheremaybemanypeoplewiththesamenameanddifferentSocialSecurityNumbers.

LetattributeArepresentSocialSecurityNumber,BrepresentgenderandCrepresentname.SurelySocialSecurityNumberandgendercanuniquelyidentifyaperson’sname.ABC).ASocialSecurityNumbercanalsouniquelyidentifyaperson’sname.AC).However,genderdoesnotuniquelydetermineaname.BCisnotvalid).

LetattributeArepresentlatitudeandBrepresentlongitude.Together,bothattributescanuniquelydetermineC,apointontheworldmap.ABC).However,neitherAnorBcanuniquelyidentifyapoint.ACandBCarenotvalid).

ExercisearelationwithattributesA1A2…An,wearetoldthattherearenofunctionaldependenciesoftheformB1B2…Bn-1CwhereB1B2…Bn-1isn-1oftheattributesfromA1A2…AnandCistheremainingattributefromA1A2…An.Inthiscase,thesetB1B2…Bn-1andanysubsetdonotfunctionallydetermineC.ThustheonlyfunctionaldependenciesthatwecanmakeareoneswhereCisonboththeleftandrighthandsides.AllofthesefunctionaldependencieswouldbetrivialandthustherelationhasnonontrivialFD’s.

Exerciseprovethisbyusingthecontrapositive.WewishtoshowthatifX+isnotasubsetofY+,thenitmustbethatXisnotasubsetofY.

IfX+isnotasubsetofY+,theremustbeattributesA1A2…AninX+thatarenotinY+.IfanyoftheseattributeswereoriginallyinX,thenwearedonebecauseYdoesnotcontainanyoftheA1A2…An.However,iftheA1A2…Anwereaddedbytheclosure,thenwemustexaminethecasefurther.AssumethattherewassomeFDC1C2…CmA1A2…AjwhereA1A2…AjissomesubsetofA1A2…An.ItmustbethenthatC1C2…CmorsomesubsetofC1C2…CmisinX.However,theattributesC1C2…CmcannotbeinYbecauseweassumedthatattributesA1A2…AnareonlyinX+andarenotinY+.Thus,XisnotasubsetofY.

Byprovingthecontrapositive,wehavealsoprovedifXY,thenX+Y+.

ExercisealgorithmtofindX+isoutlinedonpg.76.Usingthatalgorithm,wecanprovethat

(X+)+=X+.Wewilldothisbyusingaproofbycontradiction.

Supposethat(X+)+≠X+.Thenfor(X+)+,itmustbethatsomeFDallowedadditionalattributestobeaddedtotheoriginalsetX+.Forexample,X+AwhereAissomeattributenotinX+.However,ifthiswerethecase,thenX+wouldnotbetheclosureofX.TheclosureofXwouldhavetoincludeAaswell.ThiscontradictsthefactthatweweregiventheclosureofX,X+.Therefore,itmustbethat(X+)+=X+orelseX+isnottheclosureofX.

Ifallsetsofattributesareclosed,thentherecannotbeanynontrivialfunctionaldependencies.SupposeA1A2...AnBisanontrivialdependency.Then{A1A2...An}+containsBandthusA1A2...Anisnotclosed.

Iftheonlyclosedsetsareand{A,B,C,D},thenthefollowingFDshold:

ABACAD

BABCBD

CACBCD

DADBDC

ABCABD

ACBACD

ADBADC

BCABCD

BDABDC

CDACDB

ABCD

ABDC

ACDB

BCDA

Iftheonlyclosedsetsare,{A,B}and{A,B,C,D},thenthefollowingFDshold:

AB

BA

CACBCD

DADBDC

ACBACD

ADBADC

BCABCD

BDABDC

CDACDB

ABCD

ABDC

ACDB

BCDA

ExercisecanthinkofthisproblemasasituationwheretheattributesA,B,Crepresentcitiesandthefunctionaldependenciesrepresentonewaypathsbetweenthecities.Theminimalbasesaretheminimalnumberofpathwaysthatareneededtoconnectthecities.Wedonotwanttocreateanotherroadwayifthetwocitiesarealreadyconnected.

Thesystematicwaytodothiswouldbetocheckallpossiblesetsofthepathways.However,wecansimplifythesituationbynotingthatittakesmorethantwopathwaystovisitthetwoothercitiesandcomeback.Also,ifwefindasetofpathwaysthatisminimal,adding

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2