



下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
中山大学软件学院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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年镇江资格证模拟考试
- 公司合作养猪合同范本
- 冷镦模具合同范本
- 冰箱售后服务合同范本
- 农村水田改造合同范本
- 代理交易合同范本
- 兄妹赠予房产合同范本
- 北京出租车司机合同范本
- 农村承包经营户合同范本
- 临时店面员工合同范本
- DB11 938-2022 绿色建筑设计标准
- 部编版语文八年级下册第六单元名著导读《钢铁是怎样炼成的》问答题 (含答案)
- 2022译林版新教材高一英语必修二单词表及默写表
- 全国青少年机器人技术等级考试:二级培训全套课件
- 九种中医体质辨识概述课件
- (外研版)英语四年级下册配套同步练习 (全书完整版)
- 小学数学计算能力大赛实施方案
- 古诗词诵读《虞美人》课件-统编版高中语文必修上册
- 文物学概论-中国古代青铜器(上)
- 制作拉线课件
- 某物业公司能力素质模型库(参考)
评论
0/150
提交评论