南开大学数据库原理课件lecture6-Relational Algebra.ppt

南开大学数据库原理课件lecture6-Relational Algebra.ppt

ID:49584427

大小:631.50 KB

页数:66页

时间:2020-02-28

南开大学数据库原理课件lecture6-Relational Algebra.ppt_第1页
南开大学数据库原理课件lecture6-Relational Algebra.ppt_第2页
南开大学数据库原理课件lecture6-Relational Algebra.ppt_第3页
南开大学数据库原理课件lecture6-Relational Algebra.ppt_第4页
南开大学数据库原理课件lecture6-Relational Algebra.ppt_第5页
资源描述:

《南开大学数据库原理课件lecture6-Relational Algebra.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、关系查询语言(RelationalQueryLanguages)Formal:RelationalAlgebra,RelationalCalculus,DatalogPractical:SQL,QUEL,QBE(Query-by-Example)Whatisarelationalquery?Input:anumberofrelationsinyourdatabaseOutput:onerelationastheanswer关系代数(RelationalAlgebra)Union,intersection,anddifferenceSele

2、ction:pickingcertainrows.Projection:pickingcertaincolumns.Productsandjoins:compositionsofrelations.Renamingofrelationsandattributes.BasicSetOperationsUnionR:=R1∪R2IntersectionR:=R1∩R2DifferenceR:=R1-R2OperandsmusthavethesameschemaProductPaireachtuplet1ofR1witheachtuplet2o

3、fR2.Concatenationt1t2isatupleofR3.SchemaofR3istheattributesofR1andthenR2,inorder.ButbewareattributeAofthesamenameinR1andR2:useR1.AandR2.A.ExampleR(ABC)257269367S(ABC)269289367R∪S(ABC)257269367289RS(ABC)257R∩S(ABC)269367RS(ABCABC)25726925728925736926926926928926936736726

4、9367289367367SelectionCisacondition(asin“if”statements)thatreferstoattributesofR2.R1isallthosetuplesofR2thatsatisfyC.TheExampleofSelectionSellsbarbeerpriceJoe’sBud2.50Joe’sMiller2.75Sue’sBud2.50Sue’sMiller3.00barbeerpriceJoe’sBud2.50Joe’sMiller2.75SelectOperation–ExampleR

5、elationrABCD15122377310A=B^D>5(r)ABCD123710CompositionofOperationsCanbuildexpressionsusingmultipleoperationsExample:A=C(rxs)rxsA=C(rxs)AB11112222CD 1019201010102010EaabbaabbABCDE122102020aabProjectionLisalistofattributesfromtheschemaof

6、R2.R1isconstructedbylookingateachtupleofR2,extractingtheattributesonlistL,intheorderspecified,andcreatingfromthosecomponentsatupleforR1.Eliminateduplicatetuples,ifany.TheExampleofProjectionSellsbarbeerpriceJoe’sBud2.50Joe’sMiller2.75Sue’sBud2.50Sue’sMiller3.00beerpriceBud

7、2.50Miller2.75Miller3.00Theta-JoinTaketheproductThenapplytotheresult.Ccanbeanyboolean-valuedcondition.HistoricversionsofthisoperatorallowedonlyAB,whereis=,<,etc.;hencethename“theta-join.”CSells(bar,beer,price)Bars(name,addr)Joe’sBud2.50Joe’sMapleSt.Joe’sMiller2.75Sue’sR

8、iverRd.Sue’sBud2.50Sue’sCoors3.00BarInfo:=SellsSells.bar=Bars.nameBarsbar,beer,price,name,addrJo

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。