Presentation is loading. Please wait.

Presentation is loading. Please wait.

Example: Banking Database

Similar presentations


Presentation on theme: "Example: Banking Database"— Presentation transcript:

1 Example: Banking Database
國立東華大學試題: 資料庫管理 資訊管理學系 1. branch 2. customer 3. depositor 存款戶 Example: Banking Database 分公司 客戶(存款戶,貸款戶) 4. borrower 貸款戶 5. account 存款帳 6. loan 貸款帳

2 Question 1: Write SQL and Output the Results (20%)
Using the Example -- Banking Database, answering the queries: Find the loan number for each loan of an amount greater than $1200 Find the names of all branches in the loan relations, and remove duplicates How many tuples of the following statement? select  from borrower, loan How many tuples of the following statement? And what is the output? select distinct customer-name from borrower, loan where borrower loan-number = loan.loan-number and branch-name = ‘Perryridge’

3 Question 2: Updates (10%) Query: Increase all accounts with balances over $700 by 6%, all other accounts receive 5%. Consider two update statements: update account set balance = balance  where balance > 700 update account set balance = balance  where balance  700 (a) Give the account table after execute the above two update statements. (b) The order is important, why? (c) Please write a SQL by using the case statement for above update statements.

4 Question 3: Definition of Relation (15%)
Formally, given sets D1, D2, …. Dn D1 x D2 x … x Dn = {(a1, a2, …, an) | where each ai  Di} a Relation r is a subset of D1 x D2 x … x Dn Thus a relation is a set of n-tuples (a1, a2, …, an) where each ai  Di D1 = { } D2 = { } D3 = { } D1 x D2 x D3 = account = a) Write b) Write c) Why the Relation r is a subset of D1 x D2 x … x Dn , please explain it by using above example. account

5 Question 4: Composition of Operations (10%)
We can build expressions by using multiple operations Example: expression: A=C(r x s) op1: r x s op2: A=C(r x s) A B 1 2 C D   10 20 E a b A B 1 2 r a) ? s C D E 10 20 a b A B C D E 1 2 10 20 a b b) ?

6 Assume we have two queries: Q1 and Q2 as follows:
Question 5: View (15%) Assume we have two queries: Q1 and Q2 as follows: Q create view big-customer as (select account-number, branch-name from account where balance > 500 Q select * from big-customer a) Draw the result of Q2 b) If we want to add a new tuple to big-customer insert into big-customer values (‘A-999’, ‘Hualien’) Where the insertion values will be placed? Draw a table to show your answer. c) What are the advantages of the View?

7 Question 6: Comparison (10%)
Query: “Find the names of all customers who have a loan at the Perryridge branch. Query 1 customer-name (branch-name = “Perryridge” ( borrower.loan-number = loan.loan-number (borrower x loan))) a) ? Query 2 customer-name (loan.loan-number = borrower.loan-number ( (branch-name = “Perryridge” (loan)) x borrower)) b) ? c) Which one is better? Why?

8 Question 7: Overall System Structure (20%)
Draw the Overall System Structure and explain the following terms Query Processor Storage Manager Database administrator Application programmers Authorization and Integrity Manager Data dictionary Query evaluation engine DDL Interpreter DML Compiler


Download ppt "Example: Banking Database"

Similar presentations


Ads by Google