数据库复习题2答案.docx
- 文档编号:3169756
- 上传时间:2022-11-18
- 格式:DOCX
- 页数:11
- 大小:369.47KB
数据库复习题2答案.docx
《数据库复习题2答案.docx》由会员分享,可在线阅读,更多相关《数据库复习题2答案.docx(11页珍藏版)》请在冰豆网上搜索。
数据库复习题2答案
复习题
(2)
1、试分别判断下列图中G1和G2是否互模拟(bisimulation),并说明理由:
答案:
(1)在图中标出各点的状态,我们构造关系
,
可知G2可以模拟G1,下面我们讨论
是否可模拟,在G2中
有一个a变换可对应到G1中2个变换,即
,
。
但
有两个变换b,c,而在G1中仅存在只有b或只有c的状态点,可知G1和G2不能互模拟。
(2)如图,标出各状态点,构造有关系
可知其中G1中的点均可由G2中的点模拟,下面我们考虑
可知同样其中G2中的点均可由G1中的点模拟.所以G1和G2为互模拟的。
2、给定如下数据图(DataGraph):
试给出其StrongDataGuide图
答案:
StrongDataGuide图
3、Considertherelation,r,showninFigure5.27.Givetheresultofthefollowingquery:
Figure5.27
Query1:
selectbuilding,roomnumber,time_slo_id,count(*)
fromr
groupbyrollup(building,roomnumber,time_slo_id)
Query1:
selectbuilding,roomnumber,time_slo_id,count(*)
fromr
groupbycube(building,roomnumber,time_slo_id)
答案:
Query1
返回结果集:
为以下四种分组统计结果集的并集且未去掉重复数据。
building
roomnumber
time_slo_id
count(*)
产生的分组种数:
4种;
第一种:
groupbyA,B,C
Garfield
359
A
1
Garfield
359
B
1
Saucon
651
A
1
Saucon
550
C
1
Painter
705
D
1
Painter
403
D
1
第二种:
groupbyA,B
Garfield
359
A
2
Garfield
359
B
2
Saucon
651
A
1
Saucon
550
C
1
Painter
705
D
1
Painter
403
D
1
第三种:
groupbyA
Garfield
359
A
2
Garfield
359
B
2
Saucon
651
A
2
Saucon
550
C
2
Painter
705
D
2
Painter
403
D
2
第四种:
groupbyNULL。
本没有groupbyNULL 的写法,在这里指是为了方便说明,而采用之。
含义是:
没有分组,也就是所有数据做一个统计。
例如聚合函数是SUM的话,那就是对所有满足条件的数据进行求和。
Garfield
359
A
6
Garfield
359
B
6
Saucon
651
A
6
Saucon
550
C
6
Painter
705
D
6
Painter
403
D
6
Query2:
groupby后带rollup子句与groupby后带cube子句的唯一区别就是:
带cube子句的groupby会产生更多的分组统计数据。
cube后的列有多少种组合(注意组合是与顺序无关的)就会有多少种分组。
返回结果集:
为以下八种分组统计结果集的并集且未去掉重复数据。
building
roomnumber
time_slo_id
count(*)
产生的分组种数:
8种
第一种:
groupbyA,B,C
Garfield
359
A
1
Garfield
359
B
1
Saucon
651
A
1
Saucon
550
C
1
Painter
705
D
1
Painter
403
D
1
第二种:
groupbyA,B
Garfield
359
A
2
Garfield
359
B
2
Saucon
651
A
1
Saucon
550
C
1
Painter
705
D
1
Painter
403
D
1
第三种:
groupbyA,C
Garfield
359
A
1
Garfield
359
B
1
Saucon
651
A
1
Saucon
550
C
1
Painter
705
D
2
Painter
403
D
2
第四种:
groupbyB,C
Garfield
359
A
2
Garfield
359
B
2
Saucon
651
A
1
Saucon
550
C
1
Painter
705
D
1
Painter
403
D
1
第五种:
groupbyA
Garfield
359
A
2
Garfield
359
B
2
Saucon
651
A
2
Saucon
550
C
2
Painter
705
D
2
Painter
403
D
2
第六种:
groupbyB
Garfield
359
A
2
Garfield
359
B
2
Saucon
651
A
1
Saucon
550
C
1
Painter
705
D
1
Painter
403
D
1
第七种:
groupbyC
Garfield
359
A
2
Garfield
359
B
1
Saucon
651
A
2
Saucon
550
C
1
Painter
705
D
2
Painter
403
D
2
第八种:
groupbyNULL
Garfield
359
A
6
Garfield
359
B
6
Saucon
651
A
6
Saucon
550
C
6
Painter
705
D
6
Painter
403
D
6
4、[DisksandAccessTime]Consideradiskwithasector扇区sizeof512bytes,63sectorspertrack磁道,16,383trackspersurface盘面,8double-sidedplatters柱面(i.e.,16surfaces).Thediskplattersrotateat7,200rpm(revolutionsperminute).Theaverageseektimeis9msec,whereasthetrack-to-trackseektimeis1msec.
Supposethatapagesizeof4096bytesischosen.Supposethatafilecontaining1,000,000recordsof256byteseachistobestoredonsuchadisk.Norecordisallowedtospantwopages(usethesenumbersinappropriateplacesinyourcalculation).
(a)Whatisthecapacityofthedisk?
(b)Ifthefileisarrangedsequentiallyonthedisk,howmanycylindersareneeded?
(c)Howmuchtimeisrequiredtoreadthisfilesequentially?
(d)Howmuchtimeisneededtoread10%ofthepagesinthefilerandomly?
Answer:
(a)Capacity=sectorsize*num.ofsectorspertrack*num.oftrackspersurface*numofsurfaces=512*63*16383*16=8455200768
(b)File:
1,000,000recordsof256byteseach
Numofrecordsperpage:
4096/256=16
1,000,000/16=62,500pagesor62,500*8=500,000sectors
Eachcylinderhas63*16=1,008sectors
Soweneed496.031746cylinders.
(c)Weanalyzethecostusingthefollowingthreecomponents:
Seektime:
Thisaccessseekstheinitialpositionofthefile(whosecostcanbeapproximatedusingtheaverageseektime)andthenseeksbetweenadjacenttracks496times(whosecostisthetrack-to-trackseektime).Sotheseektimeis0.009+496*0.001=0.505seconds.
Rotationaldelay:
Thetransfertimeofonetrackofdatais1/(7200/60)=0.0083seconds.
Forthisquestion,weuse0.0083/2asanestimateoftherotationaldelay(othernumbersbetween0and0.00415arealsofine).Sotherotationaldelayfor497seeksis0.00415*497=2.06255.
Transfertime:
Ittakes0.0083*(500000/63)=65.8730159secondstotransferdatain500,000sectors.
Therefore,totalaccesstimeis0.505+2.06255+65.8730159=68.4405659seconds.
(d)numberofpages=6250
timecostperpage:
0.009(seek)+0.0083/2(rotationaldelay)+0.0083*8/63(transfer)=
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据库 复习题 答案