正在加载图片...
Appendix C Other Relational Query Languages loan loan_number branch_name amount QBE allows queries that involve arithmetic comparisons (for example,>) rather than equality comparisons,as in"Find the loan numbers of all loans with a loan amount of more than $700": loan loan_number branch_name a1101l11t 公 >700 Comparisons can involve only one arithmetic expression on the right-hand side of the comparison operation (for example,>(x +_y-20)).The expression can include both variables and constants.The space on the left-hand side of the comparison operation must be blank.The arithmetic operations that QBE supports are=,<,≤,>,≥,and-. Note that requiring the left-hand side to be blank implies that we cannot compare two distinct named variables.We shall deal with this difficulty shortly. As yet another example,consider the query"Find the names of all branches that are not located in Brooklyn."This query can be written as follows: branch branch_name branch_city assets P. Brooklyn The primary purpose of variables in QBE is to force values of certain tuples to have the same value on certain attributes.Consider the query"Find the loan numbers of all loans made jointly to Smith and Jones": borrower customer_name loan_number Smith P.x Tones -x To execute this query,the system finds all pairs of tuples in borrower that agree on the loan number attribute,where the value for the customer name attribute is "Smith"for one tuple and "Jones"for the other.The system then displays the value of the loan_number attribute. In the domain relational calculus,the query would be written as {)|3x(x,I)∈borrower x=“Smith") A3x(x,l)∈borrower∧x=ones")} As another example,consider the query "Find all customers who live in the same city as Jones":4 Appendix C Other Relational Query Languages loan loan_number branch_name amount P. QBE allows queries that involve arithmetic comparisons (for example, >), rather than equality comparisons, as in “Find the loan numbers of all loans with a loan amount of more than $700”: loan loan_number branch_name amount P. >700 Comparisons can involve only one arithmetic expression on the right-hand side of the comparison operation (for example, > ( x + y − 20)). The expression can include both variables and constants. The space on the left-hand side of the comparison operation must be blank. The arithmetic operations that QBE supports are =, <, ≤, >, ≥, and ¬. Note that requiring the left-hand side to be blank implies that we cannot compare two distinct named variables. We shall deal with this difficulty shortly. As yet another example, consider the query “Find the names of all branches that are not located in Brooklyn.” This query can be written as follows: branch branch_name branch_city assets P. ¬ Brooklyn The primary purpose of variables in QBE is to force values of certain tuples to have the same value on certain attributes. Consider the query “Find the loan numbers of all loans made jointly to Smith and Jones”: borrower customer_name loan_number Smith P. x Jones x To execute this query, the system finds all pairs of tuples in borrower that agree on the loan number attribute, where the value for the customer name attribute is “Smith” for one tuple and “Jones” for the other. The system then displays the value of the loan number attribute. In the domain relational calculus, the query would be written as {l|∃ x (x,l ∈ borrower ∧ x = “Smith”) ∧ ∃ x (x,l ∈ borrower ∧ x = “Jones”)} As another example, consider the query “Find all customers who live in the same city as Jones”:
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有