QBE一Basic Structure A graphical query language which is based (roughly)on the domain relational calculus Two dimensional syntax-system creates templates of relations that are requested by users Queries are expressed "by example" Database System Concepts-5th Edition,July 8,2005 5.17 @Silberschatz,Korth and Sudarshan
Database System Concepts - 5 5.17 ©Silberschatz, Korth and Sudarshan th Edition, July 8, 2005 QBE — Basic Structure A graphical query language which is based (roughly) on the domain relational calculus Two dimensional syntax – system creates templates of relations that are requested by users Queries are expressed “by example
QBE Skeleton Tables for the Bank Example branch branch-name branch-city assets customer customer-name customer-street customer-city loan loan-number branch-name amount Database System Concepts-5th Edition,July 8,2005 5.18 @Silberschatz,Korth and Sudarshan
Database System Concepts - 5 5.18 ©Silberschatz, Korth and Sudarshan th Edition, July 8, 2005 QBE Skeleton Tables for the Bank Example
QBE Skeleton Tables (Cont.) branch branch_name branch-city assets customer customer_name customer_stieet customer_city loan loan_number branchname a1101u1t borrower customer-name loan_number account account_number branch_nane balance depositor customer_name account_number Database System Concepts-5th Edition,July 8,2005 5.19 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 5.19 ©Silberschatz, Korth and Sudarshan th Edition, July 8, 2005 QBE Skeleton Tables (Cont.)
Queries on One Relation Find all loan numbers at the Perryridge branch. loan loan_number branch_name amount P._x Perryridge x is a variable (optional;can be omitted in above query) P.means print (display) duplicates are removed by default To retain duplicates use P.ALL loan loan_number branch_name amount P.ALL. Perryridge Database System Concepts-5th Edition,July 8,2005 5.20 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 5.20 ©Silberschatz, Korth and Sudarshan th Edition, July 8, 2005 Queries on One Relation Find all loan numbers at the Perryridge branch. _x is a variable (optional; can be omitted in above query) P. means print (display) duplicates are removed by default To retain duplicates use P.ALL
Queries on One Relation(Cont.) Display full details of all loans Method 1: loan loan-number branch-name amount P._x P._y P._z Method 2:Shorthand notation loan loan_number branch_name amount P Database System Concepts-5th Edition,July 8,2005 5.21 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 5.21 ©Silberschatz, Korth and Sudarshan th Edition, July 8, 2005 Queries on One Relation (Cont.) Display full details of all loans P._x P._y P._z Method 1: Method 2: Shorthand notation