0% found this document useful (0 votes)
15 views

Example RA

The document describes several queries on relational database tables representing bank data. It includes queries to find loans over $1200, customers with loans and/or accounts, customers with loans at a specific branch, the largest account balance, and customers with accounts at multiple branches.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Example RA

The document describes several queries on relational database tables representing bank data. It includes queries to find loans over $1200, customers with loans and/or accounts, customers with loans at a specific branch, the largest account balance, and customers with accounts at multiple branches.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

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)"


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)"


  Find all loans of over $1200"

σamount > 1200 (loan)"

  Find the loan number for each loan of an amount greater than
$1200"

∏loan_number (σamount > 1200 (loan))"

  Find the names of all customers who have a loan, an account, or both,
from the bank"

∏customer_name (borrower) ∪ ∏customer_name (depositor)"


  Find the names of all customers who have a loan at the Perryridge
branch."

∏customer_name (σbranch_name=“Perryridge"”
(σborrower.loan_number = loan.loan_number(borrower x loan)))"

  Find the names of all customers who have a loan at the 



Perryridge branch but do not have an account at any branch of 

the bank."

∏customer_name (σbranch_name = “Perryridge”"

(σborrower.loan_number = loan.loan_number(borrower x loan))) – 



∏customer_name(depositor)"
  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)))"

  Query 2"

∏customer_name(σloan.loan_number = borrower.loan_number (

(σbranch_name = “Perryridge” (loan)) x borrower))"
  Find the largest account balance"
  Strategy:"
  Find those balances that are not the largest"
–  Rename account relation as d so that we can compare each
account balance with all others"
  Use set difference to find those account balances that were not found
in the earlier step. "
  The query is:"

∏balance(account) - ∏account.balance"
(σaccount.balance < d.balance (account x ρd (account)))"
  Find the names of all customers who have a loan and an account at
bank."

∏customer_name (borrower) ∩ ∏customer_name (depositor)"

  Find the name of all customers who have a loan at the bank and the
loan amount"

∏customer_name, loan_number, amount (borrower loan)"


  Find all customers who have an account from at least the “Downtown”
and the Uptown” branches."
  Query 1"

∏customer_name (σbranch_name = “Downtown” (depositor account )) ∩"

∏customer_name (σbranch_name = “Uptown” (depositor account))"

You might also like