版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、中山大学软件学院软件工程专业2008级(2010秋天学期)SE-304数据库系统原理期末试题参照答案(A卷)(考试形式:开卷考试时间:2小时)Question1.DatabaseDesign(18points)Abuscompanywantstokeeptrackofitsbusroutesandschedules.Answerthequestionsaccordingtothefollowingdescription:Eachbusroutehasaroutenumber,adeparturestationandadestinationstation.Foreachbusroute,ther
2、eisaschedule,whichrecordsthedeparturetimesofbuses.Foreachdeparturetimeofeachroute,adriverandabuscanbeassigned(howeverthisisnotnecessary-informationaboutthedriverorthebusmaysometimesbemissing)AdriverhasanemployeeId,anameandaphonenumber.Abusisidentifiedbyitslicensenumber.Thedatabasealsorecordstheseati
3、ngcapacityofeachbus.(a)(10points)DrawanERdiagramforthedatabase,identifyallconstraintsandkeys,andwritedownanyassumptionsyouhavemade.(8points)ConstructappropriaterelationschemasfortheERdiagramin(a),underlinetheprimarykeys.Solution:(a)10points(b)8pointsRoute(Number#,departurestation,destinationstation)
4、Schedule(Route_Number#,departuretime)Driver(id#,name,phone)Bus(licence#,capacity)Drives(Number#,departuretime,Driver_id#)Bus_In_Use(Number#,departuretime,licence#)第-1-页/共8页Question2.RAandSQL(16points)Supposeabookstorehasthefollowingfiverelationaltables:BOOK(BID,TITLE,AID,SUBJECT,QUANTITY-IN-STOCK)AU
5、THOR(AID,FIRST-NAME,LAST-NAME)CUSTOMER(CID,FIRST-NAME,LAST-NAME)ORDER-DETAILS(OID,BID,QUANTITY)ORDER(OID,CID,ORDER-YEAR)ASSUMPTIONS:Keysareunderlinedandforeignkeysareinitalics.Eachauthorhasauthoredatleastonebookinthestore.Eachbookhasexactlyoneauthor.Eachorderismadebyexactlyonecustomerandhasoneormore
6、associatedrecordinORDER-DETAILS(e.g.,anordermaycontaindifferentbooks).WritethefollowingqueriesinRA(relationalalgebra)andSQL:(a)Findalldistinctbooktitlesoftheauthorwhoselastnameis“Lee”.(b)Findthelastnameandfirstnameofallauthorswhowrotebooksinatleasttwosubjects.Solution:(a)algebra:(BOOKAUTHOR.AID=BOOK
7、.AIDAUTHOR)TITLE(LAST-NAME=“Lee”SQL:SELECTDISTINCTB.TITLEFROMBOOKB,AUTHORAWHEREA.LAST-NAME=“Lee”ANDA.AID=B.AID(b)第-2-页/共8页Question3.ConstraintsandNormalization(16points)Inreality,FDsaregivenimplicitlyintheformofconstraintswhendesigningadatabase.LetarelationR=(Title,Length,Theater,City)wheretitleisth
8、enameofamovie,lengthisthemovielength,theateristhenameofatheaterplayingthemovieandcityisthecitywherethetheaterislocated.Giventhefollowingconstraints:Thesamenamemovieshavethesamelength.Twodifferentcitiescannothavetheaterswiththesamename.Twodifferenttheatersinthesamecitycannotplaythesamemovie.Atheaterc
9、anplaymanymovies.(6points)Writethesetoffunctionaldependenciesimpliedbytheaboveassumptions.TitleLengthTheaterCityCity,TitleTheater(4points)Identifythecandidatekey(s),andisRa3NForBCNFrelation?City,TitleandTheater,Title.3NF,notBCNF(6points)IfRisnotBCNF,decomposeittoBCNF.R1Title,Length,R2Theater,City,R3
10、Theater,Title第-3-页/共8页Question4.QueryOptimization(18points)ConsidertworelationalfilesStudent(s_id,name,dept_id,address),Enroll(class_id,student_id,semester,grade).TheStudentfilecontains10,000recordsin1,000pagesandtheEnrollfilecontains50,000recordsin5,000pages.Thereare10differentdepartmentsand25diffe
11、rentclasses.Allattributeshavethesamelength.Eachindex,whereveravailable,isatreewith3levels.Fornon-clusteringindexes,eachpointerisassumedtoleadtoadifferentpage.Ourgoalistoprocessthequery:SELECTS.nameFROMStudentS,EnrollEWHERES.dept_id=COMPANDE.class_id=530andS.S_id=E.Student_idSomeusefulstatistics:Astu
12、dentenrollsontheaveragein5classesAdepartmentcontainsontheaverage1,000studentsEachclasscontainsanaverageof2000enrolmentrecords(5points)ConsiderthattheStudentfilecontainsaclusteredindexondept_id,andtheEnrollfilecontainsanon-clusteredindexonstudent_id.Describeafullypipelinedplan(i.e.,donotmaterializean
13、ything)forprocessingthequerybyusingStudentsastheouterrelationandtakingadvantageofbothindexes.(b)(4points)Estimatetheapproximatecostofyourplan.Selectionneedstoread3+100pagesofStudents(clusteredindexondept_id)andwillreturn1,000studentidsandnames.Foreach(ofthe1,000)studentweusetheindexons_id(forEnroll)
14、tofindthecorrespondingrecord:cost=1,000(3+5)=8,000(foreachs_idweretrieve5recordsinclasses).Totalcost=8103pages.(thiscostdoesnotincludeanextralevelofindirectionforthenon-clustereds_idindex-ifwealsoincludethisthecostbecomes9103)(c)(9points)Forthefollowingquestions,assumethattherearenoindexes.Usingthea
15、bovefilesizes,estimatethecostofblocknestedloopswithamainmemorybufferof102pages(foreachcaseexplainbriefly):Studentastheouterrelation:1,000+5,000*10=51,000Enrollastheouterrelation:5,000+1,000*50=55,000Whatistheminimalcostthatyoucanachieveandhowmanymemorypagesyouneedtoachieveit?第-4-页/共8页Theminimalcosti
16、sthatofreadingbothfiles(6,000pages).Itcanbeachievedusingabufferof1,002pages(assumingStudentsastheouterrelation).第-5-页/共8页Question5.IndexingandStoragestructure(18points)Supposethatweareusingextendablehashingindexthatcontainsthefollowingsearch-keyvaluesK:1,4,5,7,8,2,20.Assumingthesearch-keyvaluesarriv
17、einthegivenorder(i.e.1beingthefirstcomingkeyand20beingthelastone).Showtheextendablehashstructureforeachinsertionoftheabovekeyvaluesfileifthehashfunctionish(x)=xmod8andbucketscanholdtwokeys.Theinitialconfigurationofthestructureandthebinaryform(assumingthechoiceofbitsstartingfromLeastSignificantBit(LS
18、B)ofallkeysaregiveninthediagrambelow.InitialhashtableEmptybucketBinaryvaluesofallkeysKInsert1,4Insert5110411152100480110211152Insert7,872Insert第-6-页/共8页220048012101511222733000800130104200112100151011102111227Insert20第-7-页/共8页Question6.TransactionManagement(14points)ConsiderthescheduleSthatconsistsoffourtransactionsasfollows:S=.Thenotationisself-explanatory.Forexample,T2_R(X)meansthattransactionT
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 初级护师专业实践能力章节练习(操作技能强化)
- 审计师(初级)审计相关基础知识模拟卷
- 临床医学检验技术专业知识历年真题解析与练习
- 2027年资产公司合同二篇
- 东方花苑小区物业管理服务委托合同
- 2025年土壤传感器提升智能花盆种植体验研究
- 企业企业文化推广方案协议
- 珠宝首饰行业节能减排协议2026
- 江苏省自考12573无线传感网技术高频考点重点
- 电路基础技术 7
- 人音版(2024)一年级上册音乐全册教案
- 口腔科标准预防规范
- 统编版(2024)八年级上册道德与法治全册知识点考点提纲填空练习版(含答案)
- 儿童营养需求的调节与膳食指导
- 2025年河北物流集团招聘笔试参考题库含答案解析
- TD/T 1042-2013土地整治工程施工监理规范
- JG/T 161-2016无粘结预应力钢绞线
- 恋爱合同书(2025年版)
- JTG-T B05-2004 公路项目安全性评价指南
- 教学课件:《食品安全学》
- DL∕T 1700-2017 隔离开关及接地开关状态检修导则
评论
0/150
提交评论