中山大学软件学院《SE304数据库系统原理》期末考试试卷(B)_第1页
中山大学软件学院《SE304数据库系统原理》期末考试试卷(B)_第2页
中山大学软件学院《SE304数据库系统原理》期末考试试卷(B)_第3页
中山大学软件学院《SE304数据库系统原理》期末考试试卷(B)_第4页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

中山大学软件学院2009级软件工程专业(2010学年春天学期)《SE-304数据库系统原理》期末考试一试卷(B)(考试形式:开卷考试时间:2小时)《中山大学授与学士学位工作细则》第六条警示考试舞弊不授与学士学位方向:姓名:学号:Question1LogicalDatabases(20marks)YouarerequiredtoconstructanERDiagramforarestaurantwhichmaintainsdataaboutthefollowingthreeentities:dish,staffandtransaction.Thethreerelationshipsarebill,cookandprocessed-byandthedetailsoftherelationshipsaredescribedasfollows:?Arecordindishisuniquelyidentifiedbyafive-digitdish-code,andcontainstheinformationforthenameofthedish,thepriceofthedish;Astaffmemberhasstaff-id,name,andworking-time-info;Eachdishiscookedbyexactlyonestaffmember,butastaffmembercancookmorethanonedishes,assumethatallthestaffmemberscancookforsimplicity;Atransactioncanbeuniquelyidentifiedbythefollowinginformation:date,time,andtheresponsiblestaffwhohasprocessedthetransaction.Morethanoneunitsofthesamedishcouldbesoldandshouldberecordedbyadistincttransaction,thisrelationshipiscalledbill.(15marks)DrawtheERdiagramthatconsistsofthethreeentitiesandthethreerelationships.YoushouldwritedowntheassumptionsclearlyifyouthinkthattheabovedescriptionofthethreeentitiesandthreerelationshipsisnotadequatefordrawingtheERDiagram.YoushouldalsoindicateallimportantinformationoftheERDiagramsuchaskeys,weakentitiesandcardinalities.(5marks)ConverttheaboveERDiagramintothecorrespondingrelationalschemas.Underlinealltheattribute(s)oftheprimarykey.Specifyclearlywhetheraschemaisobtainedfromanentity,aweakentityorarelationship.第1页,共5页Question2IndexingStructure(18marks)Supposethatweareusingextendablehashingindexthatcontainsthefollowingsearch-keyvaluesK:2,10,10,12,15,15,3,13.Assumingthesearch-keyvaluesarriveinthegivenorder(i.e.2beingthefirstcomingkeyand13beingthelastone).Showtheextendablehashstructureforeachcaseofinsertingagroupoftheabovekeyvaluesifthehashfunctionish(x)=xmod16andbucketscanholdtwokeys.Theinitialconfigurationofthestructureandthebinaryformofallkeysaregiveninthediagrambelow.Conventionrequirement:Youshouldusethebitsstartingfromthemost-significantoneorMSB(theleft-handside)asthehashingindex.InitialhashtableEmptybucketBinaryvaluesofallkeysKAfterinserting2,10,10;Afterinserting12;Afterinserting15,15,3,13.第2页,共5页Question3(22marks)JoinAlgorithmsConsiderthefollowingtworelationsRandS.ThenumberofrecordsinRandSisalsogiven.R(A,B,C,D):5,000recordsS(A,E,F,G):18,000recordsThesizesofallattributevaluesaregiveninthetable.ABCDEFG10bytes20bytes30bytes20bytes50bytes20bytes20bytesAssumethesizeofeachmemorypageis4Kbytesandthememorybufferhas25pages.Allthecomputationsshouldshowthesteps.ConsiderthefollowingSQLquery:Query:SELECTC,EFROMR,SWHERER.A=S.A(4marks)WhatisthesizeofRandSintermsofpages?(18marks)Assumeusingsort-mergejointoprocessthequeryasfollows:Step1:SortRonR.Aandstorethesortedrelationindisk,assumingwediscardirrelevantattributesassoonaspossible.(Note:Youmayneedtorounduptowholepageafterremovingtheirrelevantattributesinthefirstpass.)Step2:SortSonS.AbutcomparewithR(sortedalreadyinStep1)onceasortedpageofSisgeneratedinthefinalpass,assumingagainwediscardirrelevantattributesassoonaspossible.(Note:Spagesgeneratedinthefinalpassdonotneedtowritebacktodisk.)Sept3:TransfersortedRpagebypagefromdisktomemorybuffertocomparethesortedpagesofSonceasortedpageisgeneratedinStep.2Estimatethecostofeachstepandthencomputethetotalcostofsort-mergejoin.第3页,共5页Question4(20marks)PhysicalDatabaseDesignConsiderthefollowingschemaswithusualmeaning:Studentsandprofessorsbelongtosomedepartments.Studentsareenrolledinthecoursesofferedbysomeprofessors.Thesizeofalltheattributevaluesisassumedtobethesameineachschema.TABLES:NoofrecordsNoofpagesDEPARTMENT(D_ID,D_NAME,HEAD_ID)10020PROFESSOR(P_ID,P_NAME,SALARY,D_ID)1,000100STUDENT(S_ID,S_NAME,D_ID)10,0001,000COURSE(C_ID,C_NAME,D_ID)1,000100OFFERING(O_ID,C_ID,YEAR,SEMESTER,P_ID)10,0001,000ENROLL(S_ID,O_ID,GRADE)100,00010,000Generalinformation:Thereare500differentprofessornames,1,000differentstudentnames,and100differentdepartmentnames.Ontheaverage,eachstudentisenrolledin10offeringsandeachofferinghas10students.Eachdepartmentoffers10courses.Assumethatprofessorsalariesareuniformlydistributedintherangefrom10,000to110,000.Indexinformation:Allindexpagesarestoredindisk.WeassumeB-treeswithheight3forclusteredindexstoredandtherearenooverflowbucketsforhashindex.Forindexesonanon-candidatekey,youmayhavemultipleentrieswiththesamesearchkeyentry.Wealsoignorethecrossfactorformultiplerecordswithsamesearchkeyinafileifthenumberofrecordsiswithinthepagelimit.Weoptimizethequeriesin(a)and(b)asfollows.Query1:Displaythenamesofallprofessorswhosesalaryisintherangefrom30,000to35,000.Approach1:Buildaclusteredindexonprofessor.salary.Approach2:Buildamulti-attributeindexon<salary,p_name>anddoindex-onlyscan.Whichapproachisbetter?Youranswershouldbebasedonthecostestimationwithclearexplanations.(b)Query2:Givenaprofessor’name,sfindthenameofthedepartmentthattheprofessorbelongsto.Approach1:Buildonehashindexonprofessor.p_nameandanotherhashindexondepartment.d_id.Approach2:Buildonehashindexonprofessor.p_nameandahashfileorganizationondepartment.d_idwherethedepartmentrecordsarepartitionedin5buckets.Whichapproachisbetter?Youranswershouldbebasedonthecostestimationwithclearexplanations.第4页,共5页Question5TransactionManagement(20marks)(2marks)GivetworeasonswhyaserialschedulefordatabasetransactionsisnotpracticalforcommercialDBMSs.Inthefollowingquestions,thenotationisself-explanatory.Forexample,R1(X)meanstransactionT1readsitemX.Similarly,“W”meansWRITEand“C”means“Commit”.(18marks)Foreachofthefollowingschedules,indicatewhetheritisconflictserializableandrecoverable.Ifitisconflictserializable,thenwriteoutoneequivalentserialschedule.Thefollowingisanexampleo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论