




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 教育大数据提升教学质量的创新路径
- 如何运用教育技术提升企业内训中的混合式学习效果研究报告
- 2025年房屋整体质量无损检测分析系统合作协议书
- 学生心理健康与学校教育的融合发展
- 商业视角下的数字化教学设计与实施策略
- 医疗心理辅导在疾病康复中的作用
- 提升教学质量5G网络在教育技术中的应用策略
- 合同与信息管理类
- 教育园区的办公空间与智慧图书馆建设
- 基于AI的教学管理系统开发与实践研究报告
- IT主管岗位月度绩效考核表
- 我国非密敏感信息管理体系建设:思考与策略研究
- 社区护理考试题(含参考答案)
- Citect2018完整培训手册
- 江苏省南京市六校联合体2024-2025学年高一下学期期末考试物理试卷
- DB64∕T 1914-2023 装配式混凝土结构技术规程
- 2025至2030计时器行业发展趋势分析与未来投资战略咨询研究报告
- 2025年黑龙江省龙东地区中考语文试卷真题(含标准答案解析)
- 2024年浙江金华义乌市水利工程管理有限公司招聘笔试参考题库含答案解析
- 水果购销合同模版(共2页)
- 森林防火期内在森林防火区野外用火活动申请表
评论
0/150
提交评论