مثال آخر علي اوامر bank account SQL and relational algebra

advertisement
For the following bank database,
Banking Example
branch (branch_name, branch_city, assets)
customer (customer-name, customer_street, customer_only)
account (account_number, branch_name, balance)
loan (loan_number, branch_name, amount)
depositor (customer_name, account_number)
borrower (customer_name, loan_number)
A- it is required to draw ERD with relations
B- use SQL commands to create the tables and answer the following s
1- Find all loans of over $1200 ?
σamount > 1200 (loan)
select *
from loan
where amount>1200;
-2 - Find the loan number for each loan of an amount greater than
$1200?
πloan-number (σamount > 1200 (loan))
select loan_number
from loan
where amount>1200;
3- Find the names of all customers who have a loan, an account, or both, from the
bank
∏customer-name (σ (borrower)) U ∏customer-name (σ (depositor))
Select borrower .customer_name, depositor .customer_name
From borrower, depositor;
4- Find the names of all customers who have a loan and an account at bank
∏customer-name (borrower) ∩ ∏customer-name (depositor)
Select borrower .customer_name, depositor .customer_name
From borrower, depositor
Find the name of doctor who treat ahmed
Find the patient names who take antibiotic abc
Find the room number and doctor name who treat samy
Download