教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 学前教育 >

《数据库理论与技术》复习题-2008小妖版(2)

来源:网络收集 时间:2026-08-25
导读: DataGuide 图 PS:此图为我自己画的,不知道是否正确,有懂行的麻烦看看! 10. For the DTD, XML, and XQUERY given below, answer the questions listed next. The Document Type Definition myfriend.dtd: ... ]

DataGuide 图

PS:此图为我自己画的,不知道是否正确,有懂行的麻烦看看!

10. For the DTD, XML, and XQUERY given below, answer the questions listed

next.

The Document Type Definition myfriend.dtd:

< !ELEMENT myfriends (person*)>

< !ELEMENT person (id, name?, cell-phone*, children?)> < !ELEMENT children (child*)> < !ELEMENT child (name,toys*)> < !ELEMENT name ( #PCDATA)> < !ELEMENT toys ( #PCDATA)> < !ELEMENT id ( #PCDATA)> ... ] < !ELEMENT employees (emp*)>

< !ELEMENT emp (id, work-phone, (contact|address)> < !ELEMENT address (city,zip,street)> < !ELEMENT id ( #PCDATA)>]

< !ELEMENT contact ( #PCDATA)> ... ]

The XML Document friends.xml:

1

``jack''

2222

2

3333

c1

c2 t1 c2 ...

The XML Document employees.xml:

1

9999 ``me''

2

8888

c z s

The XQUERY expression:

FOR $outer in (friends.xml)//person, LET $child := $outer/children

WHERE ($outer/cellphone > 2000 )

RETURN $outer/id

FOR $inner IN (employees.xml)/employees/emp[id=$outer/id] RETURN {

$outer/cellphone $child/child

$inner/workphone $inner/address/city }

1) List the XML output that the XQUERY expression would generate when

applied to the given XML input documents.

2) Design a relational schema to store the two given XML data files.

3) List the SQL query that you would generate to execute the given XQUERY

expression on your relational database. State what final computations would remain to be done by the XQUERY processor beyond executing your SQL statement, if any.

解:

1)

1

2222 9999 2

3333

c1

c2 t1 c2 8888 c

2) person(pid, cellphone, name) child(cid, parentid, name) toy(tid, cid, toy_name) emp(pid, workphone, contact, city, zip, street) 3) person(pid, name, cellphoneSet MultiSet(cellphones), ChildSet MultiSet(children)) cellphones(cellphone)

children(name, toySet MultiSet(toys)) toys(toyname)

emp(pid, workphone, contact, city, zip, street) 4) select person.cellphone,

array( select child.name child.toy form child

where child.parentid=person.pid) as child_array,

emp.workphone, emp.city from person, child, emp

where person.pid=emp.pid AND person.cellphone>2000

11. Suppose you have to represent the information about parts. Each part has a name

(unique),and a textual description. Parts may be simple or complex. A simple part has a color but no children subparts. A complex part has a number of children subparts (which can be simple or complex), each of which may be repeated. (E.g., a car has 4 wheels.) You can assume that each part can be a child subpart of at most one other part (so each part, together with its subparts, can be viewed as a tree). Do not assume any fixed number of levels of part composition. …… 此处隐藏:160字,全部文档内容请下载后查看。喜欢就下载吧 ……

《数据库理论与技术》复习题-2008小妖版(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/595775.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)