- 0
- 0
- 约5.27千字
- 约 6页
- 2026-02-03 发布于北京
- 举报
[2.1]假设本练习中的表类似于示例2.4.1,即它们已经包含了所有行,因此我们可以通过
查看行的内容来推断设计者关于表键的意图。
T1
ABCD
a1b1c1d1
a2b3c1d2
a3b4c2d2
a4b2c2d1
(a)考虑上面的表T1。找出该表的三个候选键。其中一个键包含两列。
(b)考虑以下表T2:
T2
ABCDE
a1b1c1d1e1
a2b1c1d1e2
a3b1c2d1e1
a4b2c1d1e1
找出该表的两个候选键。
(c)创建一个与练习(a)类似的表,该表有四列和仅有四行,但只有一个候选键,由前三列
组成。请注意,前三列中的任何一对都不能区分所有行。
(d)创建一个与练习(b)类似的表,该表有五列A、B、C、D、E和仅,其中只有前四
列组成一个候选键。给出非正式的论据说明为什么该表中的其他列集不能形成键。
[2.1]AssumethatthetabofthisexercisearelikeExample2.4.1,inthattheyhavealltherows
theyareevergoingtohave,sothatwecanfigureouttheintentionsofthedesignerregardingkeys
forthetablebymerelylookingatthecontentsoftherows.
T1
ABCD
a1b1c1d1
a2b3c1d2
a3b4c2d2
a4b2c2d1
(a)ConsiderthetableT1above.Findthethreecandidatekeysforthistable.Oneofthekeyshas
twocolumns.
(b)ConsiderthetableT2,following:
T2
ABCDE
a1b1c1d1e1
a2b1c1d1e2
a3b1c2d1e1
a4b2c1d1e1
Findthetwocandidatekeysforthistable.
(c)Createanexampleofatableasinexercise(a)thathasfourcolumnsandonlyfourrows,buthas
onlyonecandidatekey,consistingofthefirstthreecolumns.Becarefulthatnopairofthefirst
threecolumnsdistinguishesallrows.
(d)Createanexampleofatableasinexercise(b)thathasfivecolumns,ABCDE,andonlyfive
rows,withonlyonecandidatekeyconsistingofthefirstfourcolumns.Giveaninformalargument
whynoothersetofcolumnsinthistableformsakey.
[2.4]使用关系代数解决涉及CAP数据库的以下查询。这些问题较为基础,旨在为接下来
的练习做热身。(a)查找所有订单数量等于或大于1000的(ordno,pid)对。(b)查找价格
在$0.50到$1.00(包括两端)之间的所有产品名称。(c)查找所有订单金额小于$500的
(ordno,cname)对。这里使用接。(d)查找所有三月份的(ordno,aname)对。这
里使用接。(e)查找所有三月份的(ordno,cname,aname)三元组。这里使用两个
连接。(f)查找所有在纽约的人所下的单个
原创力文档

文档评论(0)