The “Big Bank” banking organisation has a database as described below: Customer(
ID: 3874369 • 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
Hi,
Below are the answers-
Ans 1-
select count(*) from Account where type='cheque';
Ans 2-
select * from Employee e join worksAt wa
on e.employeeID=wa.employeeID
and occupation='teller'
and ((e.firstName like '%v%' or e.firstName like '%V%') or (e.lastName like '%v%' or e.lastName like '%V%'));
Ans 3-
select distinct firstName,lastName from Customer c join has h
on c.ID=h.ID
join Account a
on h.accNumber=a.accNumber
and floor(months_between(sysdate,dateOfBirth) /12)>65
and a.balance>5000 order by lastName;
Ans 4-
select accNumber from registered r
joi Branch b
on r.BSB=b.BSB
and r.BSB='713694'
and b.town='Mooroolbark';
Ans 5-
select * from Branch where BSB in
(
select BSB from(
select b.BSB,sum(a.balance) as max_bal from Account a join registered r
on a.accNumber=r.accNumber
join Branch b
on r.BSB=b.BSB
group by b.BSB
having sum(a.balance) in
(
select max(total_val)
from(select b.BSB,sum(a.balance) as total_val from Account a join registered r
on a.accNumber=r.accNumber
join Branch b
on r.BSB=b.BSB
group by b.BSB)
)
)
Ans 6-
select BSB, town from Branch b join worksAt w
on b.BSB=w.BSB
join Employee e
on w.employeeID=e.employeeID
and e.employeeID in(select employeeID from Employee
where REGEXP_LIKE(lastName, 'EDWARDS', 'i') and REGEXP_LIKE(firstName, 'TRISTAN', 'i'));
Ans 7-
select employeeID from Employee where employeeID not in(Select employeeID from worksAt);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.