ImageVerifierCode 换一换
格式:DOC , 页数:9 ,大小:472.51KB ,
资源ID:879063      下载积分:5 文钱
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,省得不是一点点
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.wenke99.com/d-879063.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(数据库复习题2答案.doc)为本站会员(h****)主动上传,文客久久仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知文客久久(发送邮件至hr@wenke99.com或直接QQ联系客服),我们立即给予删除!

数据库复习题2答案.doc

1、复习题(2)1、 试分别判断下列图中G1和G2是否互模拟(bisimulation),并说明理由:a a ab c cbG1= G2=a bca bc cG1 G2dd d答案:(1) 在图中标出各点的状态,我们构造关系,可知 G2 可以模拟 G1,下面我们讨论是否可模拟,在 G2 中 有一个 a 变换可对应到 G1 中 2 个变换,即 ,。但 有两个变换 b,c,而在 G1 中仅存在只有 b 或只有 c 的状态点,可知 G1 和 G2 不能互模拟。(2) 如图,标出各状态点,构造有关系可知其中 G1 中的点均可由 G2 中的点模拟,下面我们考虑可知同样其中 G2 中的点均可由 G1 中的点模

2、拟. 所以 G1 和 G2 为互模拟的。2、 给定如下数据图(Data Graph) : r1c1 c2s2s3 s6s7s10company companynameadres nameurladres“Widget”“Trento” “Gadget”“w.gp.fr”“Paris”p2p1 p3s0s1 s4s5 8s9person erson person“Smith”namepositn namephoe nameositn“Manger” “Jones”“521” “Dupont”“Sale”eploymagsceowrks-frwk-fr wrks-forc试给出其 Strong D

3、ataGuide 图答案:r1p1,p2,p3 c1,c2s0,s4,s8 s1,s9 s5 s2,s6 s3,s7 s10p2p1,p3personname positionphone name address urlceoemployeemanagesworks-forStrong DataGuide 图3、 Consider the relation, r , shown in Figure 5.27. Give the result of the following query :Figure 5.27Query 1:select building, room number, time

4、_slo_ id, count(*)from rgroup by rollup (building, room number, time_slo_ id)Query 1:select building, room number, time_slo_ id, count(*)from rgroup by cube (building, room number, time_slo_ id)答案:Query 1返回结果集:为以下四种分组统计结果集的并集且未去掉重复数据。building room number time_slo_ id count(*)产生的分组种数:4 种;第一种:group by

5、 A,B,CGarfield 359 A 1Garfield 359 B 1Saucon 651 A 1Saucon 550 C 1Painter 705 D 1Painter 403 D 1第二种:group by A,BGarfield 359 A 2Garfield 359 B 2Saucon 651 A 1Saucon 550 C 1Painter 705 D 1Painter 403 D 1第三种:group by AGarfield 359 A 2Garfield 359 B 2Saucon 651 A 2Saucon 550 C 2Painter 705 D 2Painter 4

6、03 D 2第四种:group by NULL。本没有 group by NULL 的写法,在这里指是为了方便说明,而采用之。含义是:没有分组,也就是所有数据做一个统计。例如聚合函数是 SUM 的话,那就是对所有满足条件的数据进行求和。Garfield 359 A 6Garfield 359 B 6Saucon 651 A 6Saucon 550 C 6Painter 705 D 6Painter 403 D 6Query 2:group by 后带 rollup 子句与 group by 后带 cube 子句的唯一区别就是:带 cube 子句的 group by 会产生更多的分组统计数据。

7、cube 后的列有多少种组合(注意组合是与顺序无关的)就会有多少种分组。返回结果集:为以下八种分组统计结果集的并集且未去掉重复数据。building room number time_slo_ id count(*)产生的分组种数:8 种第一种:group by A,B,CGarfield 359 A 1Garfield 359 B 1Saucon 651 A 1Saucon 550 C 1Painter 705 D 1Painter 403 D 1第二种:group by A,BGarfield 359 A 2Garfield 359 B 2Saucon 651 A 1Saucon 550

8、C 1Painter 705 D 1Painter 403 D 1第三种:group by A,CGarfield 359 A 1Garfield 359 B 1Saucon 651 A 1Saucon 550 C 1Painter 705 D 2Painter 403 D 2第四种:group by B,CGarfield 359 A 2Garfield 359 B 2Saucon 651 A 1Saucon 550 C 1Painter 705 D 1Painter 403 D 1第五种:group by AGarfield 359 A 2Garfield 359 B 2Saucon 65

9、1 A 2Saucon 550 C 2Painter 705 D 2Painter 403 D 2第六种:group by BGarfield 359 A 2Garfield 359 B 2Saucon 651 A 1Saucon 550 C 1Painter 705 D 1Painter 403 D 1第七种:group by CGarfield 359 A 2Garfield 359 B 1Saucon 651 A 2Saucon 550 C 1Painter 705 D 2Painter 403 D 2第八种:group by NULLGarfield 359 A 6Garfield 3

10、59 B 6Saucon 651 A 6Saucon 550 C 6Painter 705 D 6Painter 403 D 64、 Disks and Access TimeConsider a disk with a sector扇区 size of 512 bytes, 63 sectors per track磁道, 16,383 tracks per surface盘面, 8 double-sided platters柱面 (i.e., 16 surfaces). The disk platters rotate at 7,200 rpm (revolutions per minute

11、).The average seek time is 9 msec, whereas the track-to-track seek time is 1 msec.Suppose that a page size of 4096 bytes is chosen. Suppose that a file containing 1,000,000 records of 256 bytes each is to be stored on such a disk. No record is allowed to span two pages (use these numbers in appropri

12、ate places in your calculation).(a) What is the capacity of the disk?(b) If the file is arranged sequentially on the disk, how many cylinders are needed?(c) How much time is required to read this file sequentially?(d) How much time is needed to read 10% of the pages in the file randomly?Answer:(a) C

13、apacity = sector size * num. of sectors per track * num. of tracks per surface * num of surfaces = 512 * 63 * 16383 * 16 = 8 455 200 768(b) File: 1,000,000 records of 256 bytes eachNum of records per page: 4096/256 = 161,000,000/ 16 = 62,500 pages or 62,500 * 8 = 500,000 sectorsEach cylinder has 63

14、* 16 = 1,008 sectorsSo we need 496.031746 cylinders.(c) We analyze the cost using the following three components:Seek time: This access seeks the initial position of the file (whose cost can be approximated using the average seek time) and then seeks between adjacent tracks 496 times (whose cost is

15、the track-to-track seek time). So the seek time is 0.009 + 496*0.001 = 0.505 seconds.Rotational delay: The transfer time of one track of data is 1/ (7200/60) = 0.0083 seconds.For this question, we use 0.0083/2 as an estimate of the rotational delay (other numbers between 0 and 0.00415 are also fine)

16、. So the rotational delay for 497 seeks is 0.00415 * 497 = 2.06255.Transfer time: It takes 0.0083*(500000/63) = 65.8730159 seconds to transfer data in 500,000 sectors.Therefore, total access time is 0.505 + 2.06255 + 65.8730159 = 68.4405659 seconds.(d) number of pages = 6250time cost per page: 0.009

17、 (seek) + 0.0083/2 (rotational delay) + 0.0083*8/63 (transfer) = 0.0142 secondstotal cost = 6250 * 0.0142 = 88.77 seconds5、 Disk Page Layout The figure below shows a page containing variable length records. The page size is 1KB (1024 bytes). It contains 3 records, some free space, and a slot directo

18、ry in that order. Each record has its record id, in the form of Rid=(page id, slot number), as well as its start and end addresses in the page, as shown in the figure.Now a new record of size 200 bytes needs to be inserted into this page. Apply the record insertion operation with page compaction, if

19、 necessary. Show the content of the slot directory after the new record is inserted. Assume that you have only the page, not any other temporary space, to work with.Answer: Content of the slot directory, from left to right, is:(650, 200), (0, 200), (500, 150), (200, 300), 4, 8506、 Buffer Management

20、for File and Index Accesses Consider the following two relations: student(snum:integer, sname:char(30), major:char(25), standing:char(2), age:integer) enrolled(snum:integer, cname:char(40)The following index is available:A B+ Tree index on the attribute of the student relation.Assume that the buffer

21、 size is large enough to store multiple paths of each B+ Tree but not an entire tree.(a) Consider Query 1 and Query 2 that retrieve the snums of students who have taken Database Systems and Operating Systems, respectively, from the enrolled table. We know that Query 1 will be executed before Query 2

22、, and both queries are executed using a file scan of the enrolled table.Which replacement policy would you recommend for the buffer manager to use to support this workload?(b) Now assume that we have retrieved the snums of students who have taken Database Systems from the enrolled table. In the exac

23、t order of the retrieved snums (not necessarily in sorted order),we then retrieve the names of those students via repeated lookups in the B+ Tree on .For these repeated accesses to the index on student.snum, which replacement policy would you recommend for efficient buffer management?Query 1:select

24、snumfrom student s, enrolled ewhere s.snum=e.snum and cname like Database Systems;Query 2:select snumfrom student s, enrolled ewhere s.snum=e.snum and cname like Operating Systems;Answer: (a) Not LRU. MRU or LRU2.(b) Now we have repeated equality searches over the B+ Tree on , with no duplicate valu

25、es in the search key (because the schema does not allow a student to take the same course twice). Two possible answers:- The B+ Tree pages close to the top are repeated accessed but those at the leaf level are rarely reused. So we can use LRU.- LIFO (Last In First Out) is another possible answer. Th

26、is is because over time, we have cached most nodes close to the top in memory. So the nodes recently read from the disk are mostly close to the leaves. So LIFO will replace those leaf or close-to-leaf nodes to make room for the newly requested nodes.- We also accept other answers if the student can justify well.

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。