基本信息
文件名称:数据库关系运算.ppt
文件大小:18.49 MB
总页数:71 页
更新时间:2025-07-02
总字数:约9.93千字
文档摘要

笛卡尔积运算–例子Relationsr,s:rxs:AB??12AB????????11112222CD????????1010201010102010EaabbaabbCD????10102010Eaabbrs*第30页,共71页,星期日,2025年,2月5日笛卡尔积运算符号:rxs定义为: rxs={tq|t?randq?s}

假设r(R)和s(S)的属性不相交(即,R?S=?)。如果r(R)和s(S)的属性相交,则必须使用更名。*第31页,共71页,星期日,2025年,2月5日组合运算能够使用多个运算符建立表达式例如:?A=C(rxs)rxs?A=C(rxs)AB????????11112222CD????

????1010201010102010EaabbaabbABCDE???122???101020aab*第32页,共71页,星期日,2025年,2月5日更名运算允许我们通过命名来引用(referto)关系代数表达式结果。允许我们通过多个名字引用一个关系。例子: ?x(E) 返回表达式E,并赋予名字X如果一个关系代数表达式E有n元,则 返回表达式E,并赋予名字X,同时将属性更名为 A1,A2,….,An.*第33页,共71页,星期日,2025年,2月5日银行例子branch(branch_name,branch_city,assets)

customer(customer_name,customer_street,customer_city)account(account_number,branch_name,balance)loan(loan_number,branch_name,amount)depositor(customer_name,account_number)borrower(customer_name,loan_number)*第34页,共71页,星期日,2025年,2月5日查询例子找到贷款金额大于$1200的所有元组找到金额大于$1200的所有贷款的贷款号码?amount1200(loan)?loan_number(?amount1200(loan))找到有贷款或账户或二者的所有客户的名字?customer_name(borrower)??customer_name(depositor)*第35页,共71页,星期日,2025年,2月5日查询例子(cont.)找到在Perryridge支行有贷款的所有客户的名字找到在Perryridge支行有贷款但在任何分行没有账户的所有客户的名字?customer_name(?branch_name=“Perryridge”(?borrower.loan_number=loan.loan_number(borrowerxloan)))–

?customer_name(depositor)?customer_name(?branch_name=“Perryridge”(?borrower.loan_number=loan.loan_number(borrowerxloan)))*第36页,共71页,星期日,2025年,2月5日查询例子(cont.)找到在Perryridge支行有贷款的所有客户的名字Query2?customer_name(?loan.loan_number=borrower.loan_number(

?branch_name=“Perryridge”(loanxborrower)))Query1

?customer_name(?branch_name=“Perryridge”(

?borrower.loan_number=loan.loa