正在加载图片...
8 Appendix C Other Relational Query Languages account account_number branch_name balance P _x conditions -x=(21300and≤2000and-1500) QBE uses the or construct in an unconventional way to allow comparison with a set of constant values.To find all branches that are located in either Brooklyn or Queens,we write branch branch-name branch_city assets P x conditions x=(Brooklyn or Queens) C.1.5 The Result Relation The queries that we have written thus far have one characteristic in common: The results to be displayed appear in a single relation schema.If the result of a query includes attributes from several relation schemas,we need a mechanism to display the desired result in a single table.For this purpose,we can declare a temporary result relation that includes all the attributes of the result of the query. We print the desired result by including the command P.in only the result skeleton table. As an illustration,consider the query "Find the customer name,account number, and balance for all accounts at the Perryridge branch."In relational algebra,we would construct this query as follows: 1.Join depositor and account. 2.Project customername,account-number,and balance. To construct the same query in QBE,we proceed as follows: 1.Create a skeleton table,called result,with attributes customer name,account number,and balance.The name of the newly created skeleton table (that is,result)must be different from any of the previously existing database relation names. 2.Write the query. The resulting query is8 Appendix C Other Relational Query Languages account account_number branch_name balance P. x x conditions = ( ≥ 1300 and and ≤ 2000 ¬ 1500) QBE uses the or construct in an unconventional way to allow comparison with a set of constant values. To find all branches that are located in either Brooklyn or Queens, we write branch branch_name branch_city assets P. x x = (Brooklyn or Queens) conditions C.1.5 The Result Relation The queries that we have written thus far have one characteristic in common: The results to be displayed appear in a single relation schema. If the result of a query includes attributes from several relation schemas, we need a mechanism to display the desired result in a single table. For this purpose, we can declare a temporary result relation that includes all the attributes of the result of the query. We print the desired result by including the command P. in only the result skeleton table. As an illustration, consider the query “Find the customer name, account number, and balance for all accounts at the Perryridge branch.” In relational algebra, we would construct this query as follows: 1. Join depositor and account. 2. Project customer name, account number, and balance. To construct the same query in QBE, we proceed as follows: 1. Create a skeleton table, called result, with attributes customer name, account number, and balance. The name of the newly created skeleton table (that is, result) must be different from any of the previously existing database relation names. 2. Write the query. The resulting query is
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有