版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、數(shù)據(jù)庫系統(tǒng)基礎教程第五章答案數(shù)據(jù)庫系統(tǒng)基礎教程第五章答案數(shù)據(jù)庫系統(tǒng)基礎教程第五章答案V:1.0精細整理,僅供參考 數(shù)據(jù)庫系統(tǒng)基礎教程第五章答案日期:20 xx年X月Exercise a set:speedAverage = As a bag:speedAverage = Exercise a set:hd25080320200300160Average = 218As a bag:hd2502508025025032020025025030016016080Average = 215Exercise a set:bore15161418As a bag:bore1516141615151418
2、Exercise Classes)Exercise bags:On the left-hand side:Given bags R and S where a tuple t appears n and m times respectively, the union of bags R and S will have tuple t appear n + m times. The further union of bag T with the tuple t appearing o times will have tuple t appear n + m + o times in the fi
3、nal result. On the right-hand side:Given bags S and T where a tuple t appears m and o times respectively, the union of bags R and S will have tuple t appear m + o times. The further union of bag R with the tuple t appearing n times will have tuple t appear m + o + n times in the final result.For set
4、s:This is a similar case when dealing with bags except the tuple t can only appear at most once in each set. The tuple t only appears in the result if all the sets have the tuple t. Otherwise, the tuple t will not appear in the result. Since we cannot have duplicates, the result only has at most one
5、 copy of the tuple t.Exercise bags:On the left-hand side:Given bags R and S where a tuple t appears n and m times respectively, the intersection of bags R and S will have tuple t appear min( n, m ) times. The further intersection of bag T with the tuple t appearing o times will produce tuple t min(
6、o, min( n, m ) ) times in the final result. On the right-hand side:Given bags S and T where a tuple t appears m and o times respectively, the intersection of bags R and S will have tuple t appear min( m, o ) times. The further intersection of bag R with the tuple t appearing n times will produce tup
7、le t min( n, min( m, o ) ) times in the final result.The intersection of bags R,S and T will yield a result where tuple t appears min( n,m,o ) times.For sets:This is a similar case when dealing with bags except the tuple t can only appear at most once in each set. The tuple t only appears in the res
8、ult if all the sets have the tuple t. Otherwise, the tuple t will not appear in the result.Exercise bags:On the left-hand side:Given that tuple r in R, which appears m times, can successfully join with tuple s in S, which appears n times, we expect the result to contain mn copies. Also given that tu
9、ple t in T, which appears o times, can successfully join with the joined tuples of r and s, we expect the final result to have mno copies.On the right-hand side:Given that tuple s in S, which appears n times, can successfully join with tuple t in T, which appears o times, we expect the result to con
10、tain no copies. Also given that tuple r in R, which appears m times, can successfully join with the joined tuples of s and t, we expect the final result to have nom copies.The order in which we perform the natural join does not matter for bags.For sets:This is a similar case when dealing with bags e
11、xcept the joined tuples can only appear at most once in each result. If there are tuples r,s,t in relations R,S,T that can successfully join, then the result will contain a tuple with the schema of their joined attributes.Exercise bags:Suppose a tuple t occurs n and m times in bags R and S respectiv
12、ely. In the union of these two bags R S, tuple t would appear n + m times. Likewise, in the union of these two bags S R, tuple t would appear m + n times. Both sides of the relation yield the same result. For sets:A tuple t can only appear at most one time. Tuple t might appear each in sets R and S
13、one or zero times. The combinations of number of occurrences for tuple t in R and S respectively are (0,0), (0,1), (1,0), and (1,1). Only when tuple t appears in both sets R and S will the union R S have the tuple t. The same reasoning holds when we take the union S R. Therefore the commutative law
14、for union holds.Exercise bags:Suppose a tuple t occurs n and m times in bags R and S respectively. In the intersection of these two bags R S, tuple t would appear min( n,m ) times. Likewise in the intersection of these two bags S R, tuple t would appear min( m,n ) times. Both sides of the relation y
15、ield the same result. For sets:A tuple t can only appear at most one time. Tuple t might appear each in sets R and S one or zero times. The combinations of number of occurrences for tuple t in R and S respectively are (0,0), (0,1), (1,0), and (1,1). Only when tuple t appears in at least one of the s
16、ets R and S will the intersection R S have the tuple t. The same reasoning holds when we take the intersection S R.Therefore the commutative law for intersection holds.Exercise bags:Suppose a tuple t occurs n times in bag R and tuple u occurs m times in bag S. Suppose also that the two tuples t,u ca
17、n successfully join. Then in the natural join of these two bags R S, the joined tuple would appear nm times. Likewise in the natural join of these two bags S R, the joined tuple would appear mn times. Both sides of the relation yield the same result. For sets:An arbitrary tuple t can only appear at
18、most one time in any set. Tuples u,v might appear respectively in sets R and S one or zero times. The combinations of number of occurrences for tuples u,v in R and S respectively are (0,0), (0,1), (1,0), and (1,1). Only when tuple u exists in R and tuple v exists in S will the natural join R S have
19、the joined tuple. The same reasoning holds when we take the natural join S R.Therefore the commutative law for natural join holds.Exercise bags:Suppose tuple t appears m times in R and n times in S. If we take the union of R and S first, we will get a relation where tuple t appears m + n times. Taki
20、ng the projection of a list of attributes L will yield a resulting relation where the projected attributes from tuple t appear m + n times. If we take the projection of the attributes in list L first, then the projected attributes from tuple t would appear m times from R and n times from S. The unio
21、n of these resulting relations would have the projected attributes of tuple t appear m + n times.For sets:An arbitrary tuple t can only appear at most one time in any set. Tuple t might appear in sets R and S one or zero times. The combinations of number of occurrences for tuple t in R and S respect
22、ively are (0,0), (0,1), (1,0), and (1,1). Only when tuple t exists in R or S (or both R and S) will the projected attributes of tuple t appear in the result.Therefore the law holds.Exercise bags:Suppose tuple t appears u times in R, v times in S and w times in T. On the left hand side, the intersect
23、ion of S and T would produce a result where tuple t would appear min(v , w) times. With the addition of the union of R, the overall result would have u + min(v , w) copies of tuple t. On the right hand side, we would get a result of min(u + v, u + w) copies of tuple t. The expressions on both the le
24、ft and right sides are equivalent.For sets:An arbitrary tuple t can only appear at most one time in any set. Tuple t might appear in sets R,S and T one or zero times. The combinations of number of occurrences for tuple t in R, S and T respectively are (0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,
25、0,1), (1,1,0) and (1,1,1). Only when tuple t appears in R or in both S and T will the result have tuple t. Therefore the distributive law of union over intersection holds.Exercise that in relation R, u tuples satisfy condition C and v tuples satisfy condition D. Suppose also that w tuples satisfy bo
26、th conditions C and D where w min(v , w). Then the left hand side will return those w tuples. On the right hand side, C(R) produces u tuples and D(R) produces v tuples. However, we know the intersection will produce the same w tuples in the result.When considering bags and sets, the only difference
27、is bags allow duplicate tuples while sets only allow one copy of the tuple. The example above applies to both cases.Therefore the law holds.Exercise sets, an arbitrary tuple t appears on the left hand side if it appears in both R,S and not in T. The same is true for the right hand side.As an example
28、 for bags, suppose that tuple t appears one time each in both R,T and two times in S. The result of the left hand side would have zero copies of tuple t while the right hand side would have one copy of tuple t. Therefore the law holds for sets but not for bags.Exercise sets, an arbitrary tuple t app
29、ears on the left hand side if it appears in R and either S or T. This is equivalent to saying tuple t only appears when it is in at least R and S or in R and T. The equivalence is exactly the right sides expression.As an example for bags, suppose that tuple t appears one time in R and two times each
30、 in S and T. Then the left hand side would have one copy of tuple t in the result while the right hand side would have two copies of tuple t.Therefore the law holds for sets but not for bags.Exercise sets, an arbitrary tuple t appears on the left hand side if it satisfies condition C, condition D or
31、 both condition C and D. On the right hand side, C(R) selects those tuples that satisfy condition C while D(R) selects those tuples that satisfy condition D. However, the union operator will eliminate duplicate tuples, namely those tuples that satisfy both condition C and D. Thus we are ensured that
32、 both sides are equivalent.As an example for bags, we only need to look at the union operator. If there are indeed tuples that satisfy both conditions C and D, then the right hand side will contain duplicate copies of those tuples. The left hand side, however, will only have one copy for each tuple
33、of the original set of tuples.Exercise the operator on a relation with no duplicates will yield the same relation. Thus is idempotent.Exercise result of L is a relation over the list of attributes L. Performing the projection again will return the same relation because the relation only contains the
34、 list of attributes L. Thus L is idempotent.Exercise result of C is a relation where condition C is satisfied by every tuple. Performing the selection again will return the same relation because the relation only contains tuples that satisfy the condition C. Thus C is idempotent.Exercise result of L
35、 is a relation whose schema consists of the grouping attributes and the aggregated attributes. If we perform the same grouping operation, there is no guarantee that the expression would make sense. The grouping attributes will still appear in the new result. However, the aggregated attributes may or
36、 may not appear correctly. If the aggregated attribute is given a different name than the original attribute, then performing L would not make sense because it contains an aggregation for an attribute name that does not exist. In this case, the resulting relation would, according to the definition,
37、only contain the grouping attributes. Thus, L is not idempotent.Exercise result of is a sorted list of tuples based on some attributes L. If L is not the entire schema of relation R, then there are attributes that are not sorted on. If in relation R there are two tuples that agree in all attributes
38、L and disagree in some of the remaining attributes not in L, then it is arbitrary as to which order these two tuples appear in the result. Thus, performing the operation multiple times can yield a different relation where these two tuples are swapped. Thus, is not idempotent.Exercise we only conside
39、r sets, then it is possible. We can take A(R) and do a product with itself. From this product, we take the tuples where the two columns are equal to each other.If we consider bags as well, then it is not possible. Take the case where we have the two tuples (1,0) and (1,0). We wish to produce a relat
40、ion that contains tuples (1,1) and (1,1). If we use the classical operations of relational algebra, we can either get a result where there are no tuples or four copies of the tuple (1,1). It is not possible to get the desired relation because no operation can distinguish between the original tuples
41、and the duplicated tuples. Thus it is not possible to get the relation with the two tuples (1,1) and (1,1).Exercise PC(model,speed,_,_,_) AND speed Answer(maker) Laptop(model,_,_,hd,_,_) AND Product(maker,model,_) AND hd 100Answer(model,price) PC(model,_,_,_,price) AND Product(maker,model,_) AND mak
42、er=BAnswer(model,price) Laptop(model,_,_,_,_,price) AND Product(maker,model,_) AND maker=BAnswer(model,price) Printer(model,_,_,price) AND Product(maker,model,_) AND maker=BAnswer(model) Printer(model,color,type,_) AND color=true AND type=laserPCMaker(maker) Product(maker,_,type) AND type=pcLaptopMa
43、ker(maker) Product(maker,_,type) AND type=laptopAnswer(maker) LaptopMaker(maker) AND NOT PCMaker(maker)Answer(hd) PC(model1,_,_,hd,_) AND PC(model2,_,_,hd,_) AND model1 model2Answer(model1,model2) PC(model1,speed, ram,_,_) AND PC(model2,_speed,ram,_,_) AND model1 model2FastComputer(model) PC(model,s
44、peed,_,_,_) AND speed FastComputer(model) Laptop(model,speed,_,_,_,_) AND speed Answer(maker) Product(maker,model1,_) AND Product(maker,model2,_) AND FastComputer(model1) AND FastComputer(model2) AND model1 model2Computers(model,speed) PC(model,speed,_,_,_)Computers(model,speed) Laptop(model,speed,_
45、,_,_,_)SlowComputers(model) Computers(model,speed) AND Computers(model1,speed1) AND speed speed1FastestComputers(model) Computers(model,_) AND NOT SlowComputers(model)Answer(maker) FastestComputers(model) AND Product(maker,model,_)PCs(maker,speed) PC(model,speed,_,_,_) AND Product(maker,model,_)Answ
46、er(maker) PCs(maker,speed) AND PCs(maker,speed1) AND PCs(maker,speed2) AND speed speed1 AND speed speed2 AND speed1 speed2PCs(maker,model) Product(maker,model,type) AND type=pcAnswer(maker) PCs(maker,model) AND PCs(maker,model1) AND PCs(maker,model2) AND PCs(maker,model3) AND model model1 AND model
47、model2 AND model1 model2 AND (model3 = model OR model3 = model1 OR model3 = model2)Exercise Classes(class,_,country,_,bore,_) AND bore 16Answer(name) Ships(name,_,launched) AND launched 35000 AND launched 1921Answer(name,displacement,numGuns) Classes(class,_,_,numGuns,_,displacement) AND Ships(name,
48、class,_) AND Outcomes (ship,battle,_) AND battle=Guadalcanal AND ship=nameAnswer(name) Ships(name,_,_)Answer(name) Outcomes(name,_,_) AND NOT Answer(name)MoreThanOne(class) Ships(name,class,_) AND Ships(name1,class,_) AND name name1Answer(class) Classes(class,_,_,_,_,_) AND NOT MoreThanOne(class)Bat
49、tleship(country) Classes(_,type,country,_,_,_) AND type=bbBattlecruiser(country) Classes(_,type,country,_,_,_) AND type=bcAnswer(country) Battleship(country) AND Battlecruiser(country)Results(ship,result,date) Battles(name,date) AND Outcomes(ship,battle,result) AND battle=nameAnswer(ship) Results(ship,result,date) AND Results(ship,_,date1) AND result=damaged AND date date1Exercise R(x,y) AND z = zExer
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 寵物店店員職責說明
- 有關(guān)倉鼠的活動課程設計
- 2024年農(nóng)業(yè)展覽會場地租賃服務協(xié)議3篇
- 敬業(yè)的人物事跡(5篇)
- 常用學生期末品德評語參考(50句)
- 生活中的軸對稱課程設計
- 2024年度智能家居指紋鎖定制銷售與服務合同范本3篇
- 小班幼兒小汽車課程設計
- 電梯的控制系統(tǒng)課程設計
- 2024年國際游學教育資源共享合同3篇
- 2023新兵集訓總結(jié)發(fā)言
- 《財務管理》課程教學成果創(chuàng)新報告
- 護理基礎知識1000基礎題
- 2023-2024學年成都市武侯區(qū)數(shù)學六上期末質(zhì)量跟蹤監(jiān)視試題含答案
- 瀝青混凝土面層工序樣板表格
- 畢業(yè)設計(論文)-鐵路貨物運輸裝載加固方案設計
- 知?!坌!s校華東師大教職工校史知識競賽
- 煤礦新技術(shù)新工藝新設備和新材料演示文稿
- 漁光互補光伏發(fā)電項目選址方案
- 選詞填空(試題)外研版英語五年級上冊
- 物業(yè)公司危險源清單課件
評論
0/150
提交評論