数据库复习题2(答案)

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

复习题(2)

1、试分别判断下列图中G1和G2是否互模拟(bisimulation),并说明理由:

答案:

(1) 在图中标出各点的状态,我们构造关系

可知G2可以模拟G1,下面我们讨论

a b

c

a b c c

G1G2

d

d d a a a

b c

c b

G1= G

2=

是否可模拟,在G2中

有一个a 变换可对应到G1中2个变换,即,

。但

有两个变换b ,c ,而在G1中仅存在只有b 或只有c 的状态点,

可知G1和G2不能互模拟。

(2) 如图,标出各状态点,构造有关系

可知其中G1中的点均可由G2中的点模拟,下面我们考虑

可知同样其中G2中的点均可由G1中的点模拟. 所以G1和G2为互模拟的。

2、 给定如下数据图(Data Graph):

address r1

c1

c2

s2

s3

s6

s7

s10

company company

name name url address “Widget ”

“Trenton ”

“Gadget ”

“www.gp.fr ”

“Paris ”

p2

p1

p3

s0

s1

s4

s5

s8

s9

person

person person “Smith ”

name position name

phone name position “Manager ”

“Jones ”

“5552121”

“Dupont ”

“Sales ”

employee

manages

ceo

works-for works-for works-for ceo

试给出其Strong DataGuide 图

答案:

r1p1,p2,p3

c1,c2

s0,s4,s8

s1,s9

s5

s2,s6

s3,s7

s10

p2p1,p3

person

name

position

phone

name

address

url ceo

employee

manages

works-for

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 (*)

产生的分组种数:4种;

第一种:group by A,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

第二种:group by A,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

第三种:group by A

Garfield 359 A 2

Garfield 359 B 2

Saucon 651 A 2

Saucon 550 C 2

Painter 705 D 2

Painter 403 D 2

第四种:group by NULL。本没有group by NULL 的写法,在这里指是为了方便说明,而采用之。含义是:没有分组,也就是所有数据做一个统计。例如聚合函数是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

Query 2:

group by后带rollup子句与group by后带cube子句的唯一区别就是:

带cube子句的group by会产生更多的分组统计数据。cube后的列有多少种组合(注意组合是与顺序无关的)就会有多少种分组。

返回结果集:为以下八种分组统计结果集的并集且未去掉重复数据。

building room number time_slo_ id count(*)

产生的分组种数:8种

第一种:group by A,B,C

Garfield 359 A 1

Garfield 359 B 1

Saucon 651 A 1

相关文档
最新文档