Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-usewww.db-book.com Chapter 2: Relational.

Similar presentations


Presentation on theme: "Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-usewww.db-book.com Chapter 2: Relational."— Presentation transcript:

1 Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-usewww.db-book.com Chapter 2: Relational Model

2 ©Silberschatz, Korth and Sudarshan2.2Database System Concepts - 5 th Edition, Oct 5, 2006 Set Difference Operation – Example Relations r, s: r – s: AB  121121 AB  2323 r s AB  1111

3 ©Silberschatz, Korth and Sudarshan2.3Database System Concepts - 5 th Edition, Oct 5, 2006 Set Difference Operation Notation r – s Defined as: r – s = {t | t  r and t  s} Set differences must be taken between compatible relations. r and s must have the same arity attribute domains of r and s must be compatible

4 ©Silberschatz, Korth and Sudarshan2.4Database System Concepts - 5 th Edition, Oct 5, 2006 Example Find the names of all customers who have an account but no loan from the bank.  customer_name (depositor) -  customer_name (borrower) Depositor Borrower

5 ©Silberschatz, Korth and Sudarshan2.5Database System Concepts - 5 th Edition, Oct 5, 2006 Cartesian-Product Operation – Example Relations r, s: r x s: AB  1212 ABCDE  1111222211112222  10 20 10 20 10 aabbaabbaabbaabb CD  20 10 E aabbaabb r s

6 ©Silberschatz, Korth and Sudarshan2.6Database System Concepts - 5 th Edition, Oct 5, 2006 Cartesian-Product Operation Notation r x s Defined as: r x s = {t q | t  r and q  s} Assume 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.

7 ©Silberschatz, Korth and Sudarshan2.7Database System Concepts - 5 th Edition, Oct 5, 2006 Composition of Operations Can build expressions using multiple operations Example:  A=C (r x s) r x s  A=C (r x s) AB  1111222211112222 CD  10 20 10 20 10 E aabbaabbaabbaabb ABCDE  122122  20 aabaab

8 ©Silberschatz, Korth and Sudarshan2.8Database System Concepts - 5 th Edition, Oct 5, 2006 Banking Example 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)

9 ©Silberschatz, Korth and Sudarshan2.9Database System Concepts - 5 th Edition, Oct 5, 2006 Example Find the names of all customers who have a loan at the Mirpur branch.  customer_name (  branch_name=“Mirpur ” (  borrower.loan_number = loan.loan_number (borrower x loan))) Find the names of all customers who have a loan at the Mirpur branch but do not have an account at any branch of the bank.  customer_name (  branch_name = “Mirpur” (  borrower.loan_number = loan.loan_number (borrower x loan))) –  customer_name (depositor)

10 ©Silberschatz, Korth and Sudarshan2.10Database System Concepts - 5 th Edition, Oct 5, 2006 Examples Find out the customer names who live in Khulna city  customer_name (  customer_city=“khulna” (customer)) Find out the customer names who have an account but do not have a loan at any branch of the bank.  customer_name ( depositor ) –  customer_name (borrower)


Download ppt "Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-usewww.db-book.com Chapter 2: Relational."

Similar presentations


Ads by Google