下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
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 : 被數(shù)據(jù)庫(kù)設(shè)計(jì)者選中的用來(lái)在同一關(guān)系中區(qū)分不同元組的候選碼。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 允許投影使用算數(shù)運(yùn)算跟重命名。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 允許使用列函數(shù),并且分組。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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024煤礦安全監(jiān)控系統(tǒng)建設(shè)與維護(hù)合同
- 10 我們愛(ài)和平 第一課時(shí) 說(shuō)課稿-2023-2024學(xué)年道德與法治六年級(jí)下冊(cè)統(tǒng)編版
- 5G時(shí)代2024年電信工程合同管理策略
- 2025年度草原畜牧業(yè)生產(chǎn)與市場(chǎng)拓展合作合同3篇
- 專業(yè)凈水設(shè)備定期更新濾芯協(xié)議(2024)版B版
- 福建省南平市武夷山第三中學(xué)2020-2021學(xué)年高一數(shù)學(xué)理月考試題含解析
- 福建省南平市松溪縣職業(yè)中學(xué)2021-2022學(xué)年高一數(shù)學(xué)文模擬試卷含解析
- 生活學(xué)習(xí)收獲成長(zhǎng)
- 2024版中鐵機(jī)械設(shè)備租賃合同
- 2024年油茶林病蟲(chóng)害防治與防治效果承包合同3篇
- 復(fù)旦大學(xué)留學(xué)生入學(xué)考試模擬卷
- 醫(yī)療安全不良事件報(bào)告培訓(xùn)PPT培訓(xùn)課件
- 【信息技術(shù)應(yīng)用能力提升工程2.0】A3演示文稿設(shè)計(jì)與制作 初中語(yǔ)文《雖有嘉肴》主題說(shuō)明
- 小學(xué)四年級(jí)奧數(shù)教程30講(經(jīng)典講解)
- 爛尾樓工程聯(lián)建檢測(cè)與鑒定
- 汽車技術(shù)服務(wù)與營(yíng)銷畢業(yè)論文備選題目
- Reaxys使用方法
- 跌落測(cè)試(中文版)ISTA2A2006
- 云南省教育科學(xué)規(guī)劃課題開(kāi)題報(bào)告 - 云南省教育科學(xué)研究院
- 常用鋼材尺寸允許偏差范圍(2013)
- 蒸汽管道施工方案(20201118222709)
評(píng)論
0/150
提交評(píng)論