




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 对口汽修测试题及答案
- 2024年汽车美容师技能考核流程试题及答案
- 二手车评估市场前景调查试题及答案
- 汽车维修工的学习方法与分享试题及答案
- 智能医疗设备在健康监测中的应用案例
- 古代文学史的核心概念考题试题及答案
- 酒店隔离点防控要求课件
- 食品质检员考试的专业能力评估试题及答案
- 2025年语文考试形式变化试题及答案
- 足球考试题及答案学习通
- 部编版三年级上册音乐知识点汇总
- 法院刑事审判庭速裁庭廉政风险防控责任清单
- 生命体征的测量PPT幻灯片课件
- 吉林省吉林市高考报名登记表
- 质量保证体系结构图(共3页)
- 天然气长输管道的腐蚀与防护措施
- IEC60335-1(中文)
- 排沙泵检修工艺流程及验收标准
- 常见职业危害相应职业禁忌证(简表)
- Q-BQB_402-2009冷连轧碳素钢板及钢带
- 内蒙古自治区实施少数民族高层次骨干人才计划暂行办法内蒙古教育
评论
0/150
提交评论