版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Chapter 5 Algebraic and Logical Query Languages 第5章 代数和逻辑查询语言5.1 Relational Operations on BagsWhat is a bag?A bag means a relation that may ( or may not ) have duplicate tuples.A set means a relation without duplicate tuples.Why bags?SQL, the most important query language for relational databases, i
2、s actually a bag language.Some operations, like projection, are much more efficient on bags than sets.5.1 Relational Operations on BagsSelection applies to each tuple, so its effect on bags is like its effect on sets.Projection also applies to each tuple, but as a bag operator, we do not eliminate d
3、uplicates.Products and joins are done on each pair of tuples, so duplicates in bags have no effect on how we operate.Example: Bag SelectionR(A,B )125612A+B5 (R) =AB1212Example: Bag ProjectionR(A,B ) 125612 A (R) =A151Example: Bag ProductR(A,B )S(B,C )1234567812R S =AR.BS.BC123412785634567812341278Ex
4、ample: Bag Theta-JoinR(A,B )S(B,C )1234567812R R.BS.B S =AR.BS.BC12341278567812341278Bag UnionAn element appears in the union of two bags the sum of the number of times it appears in each bag.Example: 1,2,1 1,1,2,3,1 = 1,1,1,1,1,2,2,3Bag IntersectionAn element appears in the intersection of two bags
5、 the minimum of the number of times it appears in either.Example: 1,2,1,1 1,2,1,3 = 1,1,2.Bag DifferenceAn element appears in the difference A B of bags as many times as it appears in A, minus the number of times it appears in B.But never less than 0 times.Example: 1,2,1,1 1,2,3 = 1,1.Duplicate Elim
6、inationA BR1 22 31 2 (R)A B1 22 3Aggregation OperatorsSUMAVGMINMAXCOUNTA B1 22 31 2 SUM(B)=2+3+2=7Grouping OperatorsIf there is grouping, then the aggregation is within groups.L(R)Constructing method:Partition the tuples of R into groups. Each group consists of all tuples having one particular assig
7、nment of values to the grouping attributes in the list L. If there are no grouping attributes, the entire relation R is one group.For each group, produce one tuple consisting of:The grouping attributes values for that group andThe aggregations, over all tuples of that group, for the aggregated attri
8、butes on list L.starName, MIN(year)minYear, COUNT(titile) ctTitle(StarsIn)Renaming Operator and Sorting OperatorRenaming: Sorting: L(R)AB(R) A+BC(R)A(R) A, B (R)OuterjoinSuppose we join R S.A tuple of R that has no tuple of S with which it joins is said to be dangling.Similarly for a tuple of S.Outerjoin preserves dangling tuples by padding them with a special NULL symbol in the result.Left outerjoin R S.Right outerjoin R S.Full outerjoin R S.LRLeft OuterjoinOuterjoinRight OuterjoinOuterjoinFull OuterjoinOuterjoinExample: OuterjoinR = ( AB
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026河北衡水市第八中学招聘备考题库附答案
- 企业风险管理制度
- 2026湖北省定向北京师范大学选调生招录考试备考题库附答案
- 2026福建厦门轨道建设发展集团有限公司校园招聘备考题库附答案
- 2026福建省面向中国政法大学学生选调生选拔工作考试备考题库附答案
- 2026西安西京初级中学教师招聘参考题库附答案
- 2026贵州赫章县德卓镇卫生院招聘村医备考题库附答案
- 2026陕西理工科技发展有限公司招聘参考题库附答案
- 2026青海省海东市互助县城市管理综合行政执法局招聘参考题库附答案
- 中共玉环市委宣传部关于下属事业单位 市互联网宣传指导中心公开选聘1名工作人员的备考题库附答案
- GB/T 15231-2023玻璃纤维增强水泥性能试验方法
- ESC2023年心脏起搏器和心脏再同步治疗指南解读
- 五年级上册道德与法治期末测试卷推荐
- 重点传染病诊断标准培训诊断标准
- 超额利润激励
- GB/T 2624.1-2006用安装在圆形截面管道中的差压装置测量满管流体流量第1部分:一般原理和要求
- 兰渝铁路指导性施工组织设计
- CJJ82-2019-园林绿化工程施工及验收规范
- 小学三年级阅读练习题《鸭儿饺子铺》原文及答案
- 六宫格数独100题
- 厨房设施设备检查表
评论
0/150
提交评论