下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
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ù)庫設(shè)計者選中的用來在同一關(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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度二零二五年度國際零擔(dān)貨物運(yùn)輸合同標(biāo)準(zhǔn)范本
- 二零二五年度企業(yè)戰(zhàn)略規(guī)劃策劃合同8篇
- 二零二四年度企業(yè)人力資源培訓(xùn)課程定制與實施服務(wù)合同3篇
- 2025年版國際貨物采購合同風(fēng)險評估與管控
- 2025年度花卉綠植電商平臺戰(zhàn)略合作合同
- 2025年度海外市場營銷策劃合同
- 企業(yè)食堂外包項目合同模板2024版
- 二零二四年度企業(yè)市場調(diào)研外包服務(wù)合同2篇
- 二零二四瑜伽館學(xué)員權(quán)益保障服務(wù)合同范本3篇
- 2025年度企業(yè)合同管理智能化解決方案合同
- 電力溝施工組織設(shè)計-電纜溝
- 《法律援助》課件
- 《高處作業(yè)安全》課件
- 春節(jié)后收心安全培訓(xùn)
- 電梯操作證及電梯維修人員資格(特種作業(yè))考試題及答案
- 鍋爐本體安裝單位工程驗收表格
- 一種基于STM32的智能門鎖系統(tǒng)的設(shè)計-畢業(yè)論文
- 妊娠合并強(qiáng)直性脊柱炎的護(hù)理查房
- 2024年山東鐵投集團(tuán)招聘筆試參考題庫含答案解析
- 兒童10歲生日-百日宴-滿月酒生日會成長相冊展示(共二篇)
- 《繪本閱讀與指導(dǎo)》課程教學(xué)大綱
評論
0/150
提交評論