The “Big Bank” banking organisation has a database as described below: Customer(
ID: 3874370 • Letter: T
Question
The “Big Bank” banking organisation has a database as described below:
Customer(ID, firstName, lastName, address, email, phone, dateOfBirth) Account(accNumber, balance, type)
Branch(BSB, phone, streetAddress, town)
Employee(employeeID, firstName, lastName, address, phone, TFN, dateOfBirth) has(ID*, accNumber*)
registered(accNumber*, BSB*) worksAt(employeeID*, BSB*, occupation)
• Primary keys are underlined and foreign keys are denoted with asterisks (*).
• A customer can have more than one account and an account can be jointly owned by more than one customer.
• An employee can only work at one branch.
• All accounts must be registered with one branch.
Hardcoding of identifiers not given in the question is not permitted and will incur a penalty for the question. Only use the information provided in each question.
1. How many accounts are of type 'cheque'? (Hint: The result of your query should produce a number, not a list of records)
2. List all employees currently working as a 'teller' that have a lowercase 'v' or uppercase ‘V’ somewhere in their first or last name. Display the first and last names only.
3. Provide a list of customers who are aged over 65 and whose balance on any single account exceeds 5000 dollars. The list must appear in alphabetical order of last name then first name. If a customer has more than one account with over $5000 only include their name once in this list. Display the first and last names only.
4. List the account numbers of accounts registered with the branch identified by the BSB number 713694 in Mooroolbark.
5. Which branch holds the most money? (Hint: The result of your query should produce details of one branch only, not a list of branches) Display all details of this branch.
Do not use the SQL keyword ‘ROWNUM’ or ‘LIMIT’ to artificially find the bank with the most money. This will give you one result, but it is possible that more than one bank could have an equal amount of funds stored in it.
6. Which branch employs ‘Tristan Edwards’? (do not hardcode his employee ID into your query). Display the BSB and town of this branch.
Make sure your query performs one test that checks for upper and lower case versions of the employee’s name.
e.g. ‘TRISTAN EDWARDS’, ‘Tristan Edwards’, ‘tristan edwards’ or even ‘TrIsTaN eDwArDs’.
7. List any employee that has not been designated an occupation as yet. Display the first and last names only.
ID firstName accNumber address balance phone Customer has Account type ateOfBirt email lastName registered TFN firstName ad dress phone phone Employee worksAt Branch street Address dateOfBirt town employeel lastName BSB occupationExplanation / Answer
Query 1:
select count(accNumber) from Account where type='cheque'
Query 2:
select firstName,lastName from Employee
where employeeID in (select employeeID from worksAt where occupation='teller')
and (firstName like '%v%' or firstName like '%V%' or lastName like '%v%' or lastName like '%V%')
Query 3:
select firstName,lastName from Customer
where ID in (select ID from has where accNumber in (select accNumber from Account where balance>5000))
and (sysdate-dateOfBirth)/365.242199 > 65
order by lastName,firstName
Note: "sysdate" in this query is current system date and 365.242199 is number of days in a year.
Query 4:
select accNumber from Account where accNumber in (
select accNumber from registered where BSB in (select BSB from Branch where BSB=713694 and town='Mooroolbark')
)
(or)
select distinct accNumber from registered where BSB in (select BSB from Branch where BSB=713694 and town='Mooroolbark')
Query 5:
select BSB,phone,streetAddress,town
from Branch where BSB in (
select BSB from
(
select BSB,rank() over(partition by BSB order by desc) as branch_rank from
(
select BSB,sum(balance) as branch_total_money from registered a inner join Account b on a.accNumber=b.accNumber group by BSB
)a
)b and b.branch_rank=1
Query 6:
select BSB,town from Branch where BSB in
(
select BSB from worksAt where employeeID = (select employeeID from Employee where upper(firstName)='TRISTAN EDWARDS')
)
Query 7:
select firstName,lastName from Employee where employeeID in
(select employeeID from worksAt where occupation is null)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.