blanch-苍白球
复习题(
2
)
1
、
试分别
判断下列图中
G1
和
G2
是否互模拟
(bisimulation)
,并说明
理由
:
G
1
=
b
a
a
c
a
G
2
=
b
c
G
1
a
b
c
c
d
d
a
G
2
b
c
d
答案
:
(1)
在图中标出各点的状态,我们构造关系
,
可知
G2
可以模拟
G1
,下面我们讨论
是否可模拟,
在
G2
中
。但
有一个
a
变换可对应到
G1
中
2
个变换,即
,
有两个变换
b
,
c<
/p>
,而在
G1
中仅存在只有
b
或只有
c
的状态点,
可知
G1
和
G2
p>
不能互模拟。
(2)
如图,标出各状态点,构造有关系
可知其中
G1
中的点均可由
G2
中的点模拟,下面我们考虑
可知同样其中
G2
< br>中的点均可由
G1
中的点模拟
.
所以
G1
和
G
2
为互模拟的。
2
、
给定如下数据图
(Data
Graph)
:
r1
person
company
employee
person
p2
name
< br>s6
“
Gadget
”
p1
ceo
manages
c1
company
person
c2
works-for
ceo
add
ress
url
s10
“
”
p3
position<
/p>
name
s8
“
Dupont
”
works-
for
works-for
name
a
ddress
phone
name
po
sition
name
s0
“
Smith
”
s1
“<
/p>
Manager
”
s2
< br>“
Widget
”
s3
“
Trenton
”
s
4
“
Jones
”
s5
“
5552121
”
s7
“
Paris
”<
/p>
s9
“
Sales
”
试给出其
Strong DataGuide
图
答案:
r1
works-for
p1,p2,
p3
name
position
s0,
s4,s8
person
manag
es
p2
p1,p3
employee
ceo
c1,c2
phone
name
address
s5
< br>s2,s6
s3,s7
url
s
10
s1,s9
Strong DataGuide
图
3
、
Consider the relation,
r
, shown in
Figure
5.27
.
Give the result of the
following
query :
Figure 5.27
Query 1
:
select
building
,
room
number
,
time_slo_
id
,
count
(*)
from
r
group by
rollup
(
building
,
room number
,
time_slo_ id
)
Query 1
:
select
building
,
room
number
,
time_slo_
id
,
count
(*)
from
r
group by
cube
(
building
,
room number
,
time_slo_ id
)
答案:
Query 1
返回结果集:为以下四种分组统计结果集的并集且未去掉重复数据。
building
room
number
time_slo_
id
count
(*)
< br>产生的分组种数:
4
种;
第一种:
group by A,B,C
Garfield
Garfield
Saucon
Saucon
Painter
Painter
Garfield
Garfield
Saucon
Saucon
Painter
Painter
第三种:
group by A
Garfield
Garfield
Saucon
Saucon
Painter
Painter
359
359
651
550
705
403
A
B
A
C
D
D
2
2
2
2
2
2
359
359
651
550
705
403
359
359
651
550
705
403
A
B
A
C
D
D
A
B
A
C
D
D
1
1
1
1
1
1
2
2
1
1
1
1
第二种:
group by A,B
第四种:
group by
NULL
。
本没有
group by
NULL
的写法,在这里指是为了方便说明,
而采用之。含义
是:没有分组,也就是所有数据做一个统计。例如聚合函数是
SUM
的话,
那就是对所有满足条件的数据进行求和。
Garfield
Garfield
Saucon
Saucon
Painter
Painter
359
359
651
550
705
403
A
B
A
C
D
D
6
6
6
6
6
6
Query 2
:
group by
后带
rollup<
/p>
子句与
group by
后带
cube
子句的
唯一区别
就是:
带
cube
< br>子句的
group by
会产生更多的分组统计数据。<
/p>
cube
后的列有多少种组合
(注意组合
是与顺序无关的)就会有多少种分组。
返回结果集:为以下八种分组统计结果集的并集且未去掉重复数据。
building
room
number
time_slo_
id
count
(*)
< br>产生的分组种数:
8
种
第一种:
group by A,B,C
Garfield
359
Garfield
Saucon
359
651
A
B
A
1
1
1