下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、DataBase Chapter Two OutlineThe set of allowed values for each attribute is called the domain of the attributer(R) is a relation on the relation schema R Example:customer (Customer_schema)About Key:K is a superkey of R if values for K are sufficient to identify a unique tuple of each possible relati
2、on r(R) K is a candidate key if K is minimal (最小超码)Primary Key : 被数据库设计者选中的用来在同一关系中区分不同元组的候选码。Relational AlgebraProcedural languageSix basic operatorsselect: s project: union: set difference: Cartesian product: xrename: r The operators take one or two relations as inputs and produce a new relation a
3、s a result.Select OperationNotation: s p(r)p is called the selection predicate Defined as: sp(r) = t | t r and p(t)Where p is a formula in propositional calculus consisting of terms connected by : (and), (or), (not)Each term is one of:op or where op is one of: =, , , . . Project OperationNotation:wh
4、ere A1, A2 are attribute names and r is a relation name.Union OperationNotation: r sDefined as: r s = t | t r or t sFor r s to be valid.1. r, s must have the same arity (same number of attributes)2. The attribute domains must be compatible (example: 2nd column of r deals with the same type of values
5、 as does the 2nd column of s)Set Difference OperationNotation r sDefined as: r s = t | t r and t sSet differences must be taken between compatible relations.r and s must have the same arity attribute domains of r and s must be compatible Cartesian-Product OperationNotation r x s Defined as:r x s = t
6、 q | t r and q sAssume that attributes of r(R) and s(S) are disjoint. (That is, R S = ).If attributes of r(R) and s(S) are not disjoint, then renaming must be used.Rename OperationAllows us to name, and therefore to refer to, the results of relational-algebra expressions.Allows us to refer to a rela
7、tion by more than one name.Example: r x (E)returns the expression E under the name X If a relational-algebra expression E has arity n, then returns the result of expression E under the name X, and with theattributes renamed to A1 , A2 , ., An .Additional OperationsSet-Intersection OperationNotation:
8、 r s Defined as:r s = t | t r and t s Assume: r, s have the same arity attributes of r and s are compatibleNote: r s = r (r s)Natural-Join OperationNotation: rsLet r and s be relations on schemas R and S respectively. Then, r s is a relation on schema R S obtained as follows:Consider each pair of tu
9、ples tr from r and ts from s. If tr and ts have the same value on each of the attributes in R S, add a tuple t to the result, wheret has the same value as tr on r t has the same value as ts on s q -Join Operationrqs= s q (r x s)Division OperationNotation: Suited to queries that include the phrase “f
10、or all”.Let r and s be relations on schemas R and S respectively whereR = (A1, , Am , B1, , Bn )S = (B1, , Bn)The result of r s is a relation on schemaR S = (A1, , Am)r s = t | t R-S (r) u s ( tu r ) Where tu means the concatenation of tuples t and u to produce a single tuple r s = R-S (r ) R-S ( (
11、R-S (r ) x s ) R-S,S(r )Assignment OperationThe assignment operation () provides a convenient way to express complex queries. Write query as a sequential program consisting ofa series of assignments followed by an expression whose value is displayed as a result of the query.Assignment must always be
12、 made to a temporary relation variable.Example: Write r s as temp1 R-S (r ) temp2 R-S (temp1 x s ) R-S,S (r )result temp1 temp2 The result to the right of the is assigned to the relation variable on the left of the .May use variable in subsequent expressions.Extended Relational-Algebra-OperationsGen
13、eralized Projection 允许投影使用算数运算跟重命名。Extends the projection operation by allowing arithmetic functions to be used in the projection list.E is any relational-algebra expressionEach of F1, F2, , Fn are are arithmetic expressions involving constants and attributes in the schema of E.Given relation credit
14、_info(customer_name, limit, credit_balance), find how much more each person can spend: customer_name, limit credit_balance (credit_info) Also, we can apply rename operation:customer_name, limit credit_balance as credit_availble (credit_info) Aggregate Functions and Operations 允许使用列函数,并且分组。Aggregatio
15、n function takes a collection of values and returns a single value as a result.avg: average value min: minimum value max: maximum value sum: sum of values count: number of valuesAggregate operation in relational algebra E is any relational-algebra expressionG1, G2 , Gn is a list of attributes on whi
16、ch to group (can be empty)Each Fi is an aggregate function Each Ai is an attribute nameThe schema of result is (G1, G2 , Gn , a1, a2 , am ).where ai is the result of applying the aggregate function Fi on the multiset of values for attribute Ai in the groupOuter JoinAn extension of the join operation
17、 that avoids loss of information.Computes the join and then adds tuples form one relation that does not match tuples in the other relation to the result of the join. Uses null values:null signifies that the value is unknown or does not exist All comparisons involving null are (roughly speaking) fals
18、e by definition.We shall study precise meaning of comparisons with nulls laterThe result of any arithmetic expression involving null is null.Modification of the DatabaseDeletionCan delete only whole tuples; cannot delete values on only particular attributesA deletion is expressed in relational algebra by:r r E where r is a relation and E is a relational algebra query. InsertionTo insert data into a relation, we either:specify a tuple to be insertedwrite a query whose result is a set of tu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 股二头肌损伤病因介绍
- 教案课件下载
- 2024年度艺术家共同创作及版权归属合同3篇
- 《财务软件的应用》课件
- 关于Hobby的阅读小学英语教学教材课件
- 《客户关系管理实务》电子教案 17拜访客户
- 福建省安溪一中、养正中学、惠安一中、泉州实验中学2024-2025学年高一上学期期中联考语文试卷
- 新人教版二年级数学上册第五单元 观察物体(2)课程
- 幼儿园成长档案
- 男性性功能障碍病因介绍
- 期末测试卷(一)2024-2025学年 人教版PEP英语五年级上册(含答案含听力原文无听力音频)
- 2024中国慢性阻塞性肺疾病基层诊疗与管理指南解读
- 2024秋期国家开放大学专科《监督学》一平台在线形考(形成性考核一至四)试题及答案
- 2024广西专业技术人员继续教育公需科目参考答案(100分)
- DL∕ T 1195-2012 火电厂高压变频器运行与维护规范
- 美术课程与教学论智慧树知到期末考试答案章节答案2024年四川师范大学
- 2021~2025年给水排水工程行业调研分析报告
- IPC-A-610E培训教材(完整版)
- (最新整理)MQW-511型机动车排气分析仪说明书(HORIBA平台)20140617
- SC镀锌钢管紧定式连接施工工法(共12页)
- 元音老人问答录
评论
0/150
提交评论