Securing Higher Grades Costing Your Pocket? Book Your Assignment at The Lowest Price Now!

Database Implementation And Queries Add in library

389 Download12 Pages 2,895 Words

Questions:

A. Understanding and Implementation of the Database

Using the supplied schema file, create the database for CQR. The supplied file populates all tables to reflect the content of the artefacts provided in Assignment 1 and is a cut-down version of the practice at the close of business on 15th September 2014. . At this stage, you are to imagine what the state of the database would be at the close of business on the next day, subject to the requirements of this task, and all subsequent tasks.

Write queries to find out the following:

• Find the unused structures e.g. there is one Superannuation client but no Partnership clients on the starter database.

• Find the unused sectors;

• Find the unrequested services;

• Find the unused billing cost types;

• Find domains for which there is none or only one current employee with that expertise;

• Find the minimum billing rate for each employee type for the most recent billing rate effective date;

B. Test Data

This task will only be completed after you have finished this and all subsequent tasks. You should create a single script –

• satisfy this section’s requirements;

• satisfy the specific scenarios outlined below in section C; and

• where necessary provide meaningful data for the SQL queries specified in sectionD.

Queries that are correct and do not produce output using your test data will lose 50% of the marks allocated so you should carefully check your test data and ensure it thoroughly validates your SQL queries. For example if a query asks to display the full details for all CLIENTS who have a TAS or a NT address then at least two rows are expected to be displayed. If the data provided in the supplied schema file does not do this you need to work out a way of doing that and include in your script file.

There should be comments in the script to explain what is being done and to identify what parts of the assignment are being covered. The script should contain a single COMMIT statement as the last line of the script, i.e. all inserts should be treated as a single transaction. The data should be structured in such a way that once it has been inserted and the "commit" SQL command has been run, the database is in a consistent state.

Specifically for this section, and using the information obtained from the previous section, you should add as a minimum:

• Three new clients. These clients should:

o have a structure that has not been used yet;

o operate in sectors that have not been used yet (but may include existing ones if they operate in more than one);

o require services that have not been requested yet (but may include existing ones);

o have one unique billing on cost type charged to them for the day;

• Two new employees – one Accountant and one Administrator. They need to:

o at least work in domains for which there is none or only one current employee with that expertise;

o Have a billing rate the same as that of the same employee type with the minimum rate for that employee;

C. Specific Scenarios – Manipulate the Database

In the following section, the SQL scripts must correctly manage transactions. You should also ensure that any related data impacted by your script actions are correctly managed.

1. A new accountant is to be added (assume it has not been updated from the HR system). His name is Matthias Window. He has expertise in Taxation and Corporate affairs and will be charged out at a rate of $160.00 per hour from today (16th September 2014).

Include this new employee and his details on the CQR database. Assume that the employee number for this new employee is 1 more than the largest employee in the BILLINGEMPLOYEE table.

2. His first work is to give some tax advice to an existing client who he thinks is Bill Wilson. He spends an hour from 8:30 doing so but can’t find the service type code so creates a new one for donations and uses that. He then moves on to some research for half an hour for an existing client Richard Smith. In both cases he forgets to key in an end time.

Include the details of this sequence of billing in the database.

3. At 10:00 Matthias realises he actually worked for Bill Watson initially not Bill Wilson, that he should have used the communication code for that work and that he should have completed the times correctly.

Include the details of these corrections in the database.

4. Matthias is then tasked with completing a corporate return for 2 Boy’s Plumbing Pty. Ltd. He gets the time wrong and keys in 9:30am and spends 2 hours completing the return, updating the completion time to 11:30 when he is finished. As part of the process he raises an on-cost record for the lodgement fee ($110.00) for the return.

Include the above changes in the database.

5.  Alan Counting reduces Matthias Window’s billing rate by 25%.

D. Querying of Database using SQL Statements

1. Display the full details for all clients - the name details (firstname and lastname) should be shown in one column called 'Client Name' and the address details (street1, street2, city, state and postcode) in one column called ‘Client Address'.

2. Display the full details for all clients who have a TAS or a NT address.

3. Display the full details for all service types in the CQR service type table which have the word 'advice' (upper or lowercase) in any of their columns.    

4. Alan is considering what the effect of increasing the billing rate on all employees by 5% would be. Display the employee number, name, effective date and increased billing rate of all employees in CQR.

5. Display the full details for the cheapest billing employee provided by CQR.

6. Display the details of all clients for whom no billing on cost records exist for the current year (2014). Display in client concatenated firstname, lastname order.

7. Provide the total number of employees, total billing rate, average billing rate for the practice.

8.  Calculate the total charges, excluding on-costs per client for the month of September 2014.

9. Display the employee number, client number, service ID and billingstarttime for service types of “Advice” or “Communication” type where the actual charge on any billing record is cheaper than $150 and the time duration is between 15 and 30 minutes. Order the list such that the billingrecords which are least expensive are listed first.

10. For all clients currently in the CQR system, display details about the clients and those with sector records and those without sector records:

• for each client with sectors: display the string 'With sectors', the client number, client first name concatenated with the client last name, and the total number of sectors the client is involved in, and

• for each client without sector records: display the string 'Without sectors', the client number, client first name concatenated with the client last name, and the total number of sectors as a string of ‘Not applicable’.

11. Display details of all employees (number, name) for whom billingrecords have been created when they are not identified as having that expertise i.e. those employees who have charged to a service that they do not have a domain record for. (2 marks)

12. Select employee number and the distinct service from the billingrecords where any record for that service took in excess of 1 hour to complete. You should only display one employee number, service and description combination even when multiple records qualify.

13. Display the structure details for which the smallest total billable activity (time) has been performed in the last month – (17-08-2014 to 16-09-2014)

14. Report the average number of billing records per employee per day.
 
 

Answers:

A. Understanding and Implementation of the Database

Find the unused structures e.g. there is one Superannuation client but no Partnership clients on the starter database

Query:

SELECT * FROM structure WHERE StructureID NOT IN (SELECT StructureID FROM client);

Find the unused sectors

Query:

SELECT * FROM Sector WHERE SectorID NOT IN (SELECT SectorID FROM ClientSector);

Find the unrequested services

Query:

SELECT * FROM Service WHERE ServiceID NOT IN (SELECT ServiceID FROM ClientService);

Find the unused billing cost types

Query:

SELECT * FROM BillingOnCostType WHERE BillingOnCostTypeID NOT IN (SELECT BillingOnCostTypeID FROM BillingOnCost);

Find domains for which there is none or only one current employee with that expertise

Query:

SELECT * FROM Service WHERE ServiceID IN (SELECT ServiceID FROM EmployeeDomain WHERE EmployeeNumber IN (SELECT EmployeeNumber FROM EmployeeDomain GROUP BY EmployeeNumber HAVING COUNT(*)=0 OR COUNT(*)=1));

Find the minimum billing rate for each employee type for the most recent billing rate effective date

Query:

SELECT et.EmployeeType,ber.BillingRateEffectiveDate,MIN(ber.BillingRate) AS MinBillingRate FROM BillingEmployeeRate ber,Billing Employee be,EmployeeType et WHERE ber.EmployeeNumber=be.EmployeeNumber AND be.EmployeeType=et.EmployeeType GROUP BY et.EmployeeType,ber.BillingRateEffectiveDate order by ber.BillingRateEffectiveDate DESC limit 4;

B. Test Data:

INSERT INTO Client (ClientFirstName,ClientLastName, ClientStreet1, ClientStreet2,ClientCity,ClientState,ClientPostcode, ClientContact, ClientContactPhone,ClientTFN,ClientABN,ClientAddDate,StructureID, ClientLink) VALUES ('John','Smith','24, TT Ct','', 'Ararat','NT',3300,'Henry Micheal','09494038585','98494398438','949934892874','2015-01-01',1,168750);

INSERT INTO Client (ClientFirstName,ClientLastName, ClientStreet1, ClientStreet2,ClientCity,ClientState,ClientPostcode, ClientContact, ClientContactPhone,ClientTFN,ClientABN,ClientAddDate,StructureID, ClientLink) VALUES ('Andrew','William','72, TT Ct','81 RR Ct','Gosfort','TAS',3302,'Nitin','4737445745','984324634634','9499342637565','2015-01-06',4,null);

INSERT INTO Client (Client First Name, Client Last Name, ClientStreet1, ClientStreet2,ClientCity,ClientState,ClientPostcode, ClientContact, ClientContactPhone,ClientTFN,ClientABN,ClientAddDate,StructureID, ClientLink) VALUES ('Stephen','Oliver','90, MM Street','120 PP Ct','Morwell','NSW',4200,'Peter','834838403489','98438958934','773273459873','2015-01-12',7,124545);

INSERT INTO ClientSector(ClientNumber,SectorID) VALUES ('168754',4);

INSERT INTO ClientSector(ClientNumber,SectorID) VALUES ('168759',9);

INSERT INTO ClientSector(ClientNumber,SectorID) VALUES ('168754',7);

INSERT INTO ClientSector(ClientNumber,SectorID) VALUES ('16854',5);

INSERT INTO ClientService (ClientNumber,ServiceID) VALUES (168754,'ADM');

INSERT INTO ClientService (ClientNumber,ServiceID) VALUES (168755,'CRP');

INSERT INTO ClientService (ClientNumber,ServiceID) VALUES (168756,'RCV');

INSERT INTO ClientService (ClientNumber,ServiceID) VALUES (145968,'AUD');

INSERT INTO ClientService (ClientNumber,ServiceID) VALUES (168750,'LIQ');

INSERT INTO ClientService (ClientNumber,ServiceID) VALUES (168752,'MGT');

INSERT INTO BillingOnCost (ClientNumber, BillingOnCostDate,BillingOnCostTypeID, BillingOnCostCharge) VALUES (168754,'2015-02-01',1,30);

INSERT INTO BillingOnCost (ClientNumber, BillingOnCostDate,BillingOnCostTypeID, BillingOnCostCharge) VALUES (168755,'2015-01-25',3,60);

INSERT INTO BillingOnCost (ClientNumber, BillingOnCostDate,BillingOnCostTypeID, BillingOnCostCharge) VALUES (168756,'2015-01-27',2,8);

INSERT INTO BillingEmployee (EmployeeNumber,EmployeeName,EmployeeType) VALUES (102678,'George Queen',1);

INSERT INTO BillingEmployee (EmployeeNumber,EmployeeName,EmployeeType) VALUES (102679,'Francis Peter',2);

INSERT INTO EmployeeDomain (EmployeeNumber,ServiceID) VALUES (102677,'LIQ');

INSERT INTO BillingEmployeeRate(EmployeeNumber,BillingRateEffectiveDate,BillingRate) VALUES (102677,'2015-01-20',45);

INSERT INTO BillingEmployeeRate(EmployeeNumber,BillingRateEffectiveDate,BillingRate) VALUES (102678,'2015-01-27',60);

 

C. Manipulate the Database

A new accountant is to be added (assume it has not been updated from the HR system). His name is Matthias Window. He has expertise in Taxation and Corporate affairs and will be charged out at a rate of $160.00 per hour from today (16th September 2014).

Include this new employee and his details on the CQR database. Assume that the employee number for this new employee is 1 more than the largest employee in the BILLINGEMPLOYEE table.

INSERT INTO BillingEmployee (EmployeeNumber,EmployeeName,EmployeeType) VALUES (102680,'Matthias Window',1);

INSERT INTO BillingEmployeeRate(EmployeeNumber,BillingRateEffectiveDate,BillingRate) VALUES (102680,'2014-09-16',160);

INSERT INTO EmployeeDomain (EmployeeNumber,ServiceID) VALUES (102680,'TAX');

INSERT INTO EmployeeDomain (EmployeeNumber,ServiceID) VALUES (102680,'CRP');

His first work is to give some tax advice to an existing client who he thinks is Bill Wilson. He spends an hour from 8:30 doing so but can’t find the service type code so creates a new one for donations and uses that. He then moves on to some research for half an hour for an existing client Richard Smith. In both cases he forgets to key in an end time.

Include the details of this sequence of billing in the database.

INSERT INTO ServiceType (ServiceTypeID,ServiceTypeDescription,ServiceTypeNote) VALUES ('DONA','Donation','New Donation Scheme');

INSERT INTO BillingRecord (EmployeeNumber,BillingDate,ClientNumber,BillingStartTime,ServiceID,ServiceTypeID,BillingComment) VALUES (102680,'2014-09-16',168750,'08:30:00','TAX','DONA','New Plan');

INSERT INTO BillingRecord (EmployeeNumber,BillingDate,ClientNumber,BillingStartTime,ServiceID,ServiceTypeID,BillingComment) VALUES (102680,'2014-09-16',124545,'08:30:00','TAX','RSCH','Tax research');

At 10:00 Matthias realises he actually worked for Bill Watson initially not Bill Wilson, that he should have used the communication code for that work and that he should have completed the times correctly. Include the details of these corrections in the database.

UPDATE CLIENT SET CLIENTLASTNAME='Watson' WHERE ClientNumber=168750;

INSERT INTO BillingRecord (EmployeeNumber,BillingDate,ClientNumber,BillingStartTime,ServiceID,ServiceTypeID,BillingComment,BillingEndTime) VALUES (102680,'2014-09-16',168750,'10:00:00','TAX','COMM','Communications','11:00:00');

INSERT INTO BillingRecord (EmployeeNumber,BillingDate,ClientNumber,BillingStartTime,ServiceID,ServiceTypeID,BillingComment,BillingEndTime) VALUES (102678,'2014-09-16',168750,'06:00:00','TAX','COMM','Communications','06:20:00');

Matthias is then tasked with completing a corporate return for 2 Boy’s Plumbing Pty. Ltd. He gets the time wrong and keys in 9:30am and spends 2 hours completing the return, updating the completion time to 11:30 when he is finished. As part of the process he raises an on-cost record for the lodgement fee ($110.00) for the return.

Include the above changes in the database.

INSERT INTO BillingRecord (EmployeeNumber,BillingDate,ClientNumber,BillingStartTime,ServiceID,ServiceTypeID,BillingComment) VALUES (102680,'2014-09-16',168752,'09:30:00','CRP','MTNG','Communications')

UPDATE BillingRecord SET BillingEndTime='11:30:00' WHERE EmployeeNumber=102680 AND BillingDate='2014-09-16' AND ClientNumber=168752;

INSERT BillingOnCost (ClientNumber,BillingOnCostDate,BillingOnCostTypeID,BillingOnCostCharge) VALUES (168752,'2014-09-16',1,110);

INSERT BillingEmployeeRate (EmployeeNumber,BillingRateEffectiveDate,BillingRate) VALUES ((SELECT EmployeeNumber FROM BillingEmployee WHERE EmployeeName='Alan Counting'),'2014-09-16',200*0.75);

 

D. Querying of Database using SQL Statements

1. Display the full details for all clients - the name details (firstname and lastname) should be shown in one column called 'Client Name' and the address details (street1, street2, city, state and postcode) in one column called ‘Client Address'.

SELECT CONCAT(ClientFirstName , ' ' , ClientLastName) AS "Client Name", CONCAT(ClientStreet1,', ',IFNULL(ClientStreet2,''),', ',ClientCity,', ' ,ClientState,', ',ClientPostCode) AS "ClientAddress" FROM Client;


2. Display the full details for all clients who have a TAS or a NT address.

SELECT * FROM Client WHERE ClientState='NT' OR ClientState='TAS';


3. Display the full details for all service types in the CQR service type table which have the word 'advice' (upper or lowercase) in any of their columns

SELECT * FROM ServiceType WHERE LOWER(ServiceTypeDescription) LIKE '%advice%' OR LOWER(ServiceTypeNote) LIKE '%advice%';

4. Alan is considering what the effect of increasing the billing rate on all employees by 5% would be. Display the employee number, name, effective date and increased billing rate of all employees in CQR.

SELECT be.EmployeeNumber,be.EmployeeName,CURDATE() AS "Latest Effective Date",ber.BillingRate*1.05 AS "Increasing the BillingRate" FROM BillingEmployee be, BillingEmployeeRate ber , (SELECT EmployeeNumber, MAX(BillingRateEffectiveDate)  AS LatestBillDate FROM BillingEmployeeRate GROUP BY EmployeeNumber)  mbe WHERE be.EmployeeNumber=ber.EmployeeNumber AND (be.EmployeeNumber=mbe.EmployeeNumber AND ber.BillingRateEffectiveDate=mbe.LatestBillDate);


5. Display the full details for the cheapest billing employee provided by CQR.

SELECT emp.EmployeeNumber,emp.EmployeeName,emp.employeeType FROM BillingEmployee emp, (SELECT EmployeeNumber, MAX(BillingRateEffectiveDate)  AS LatestBillDate,BillingRate FROM BillingEmployeeRate GROUP BY EmployeeNumber ORDER BY BillingRate LIMIT 1) ne WHERE emp.EmployeeNumber=ne.EmployeeNumber;


6. Display the details of all clients for whom no billing on cost records exist for the current year (2014). Display in client concatenated firstname, lastname order.

SELECT * FROM Client WHERE ClientNumber NOT IN (SELECT ClientNumber FROM BillingOnCost WHERE YEAR(BillingOnCostDate) = 2014) ORDER BY CONCAT(ClientFirstName,ClientLastName);


7. Provide the total number of employees, total billing rate, average billing rate for the practice.

SELECT COUNT( DISTINCT(EmployeeNumber)) AS "Total Employee", SUM(BillingRate) AS "Total Billing Rate",AVG(BillingRate) AS "Average Billing Rate" FROM BillingEmployeeRate;

8. Calculate the total charges, excluding on-costs per client for the month of September 2014.

SELECT SUM(BillingOnCostCharge) AS "Total Cost Excluding September Client" FROM BillingOnCost WHERE YEAR(BillingOnCostDate)<>2014 AND MONTH(BillingonCostDate)<>9;


9. Display the employee number, client number, service ID and billingstarttime for service types of “Advice” or “Communication” type where the actual charge on any billing record is cheaper than $150 and the time duration is between 15 and 30 minutes. Order the list such that the billingrecords which are least expensive are listed first.

SELECT EmployeeNumber,ClientNumber,ServiceID, BillingStartTime FROM BillingRecord WHERE ((BillingEndTime-BillingStartTime)/100 BETWEEN  15 AND 30 ) AND ServiceTypeID IN (SELECT ServiceTypeID FROM ServiceType WHERE ServiceTypeDescription='Advice' OR ServiceTypeDescription='Communication') AND EmployeeNumber IN (SELECT EmployeeNumber FROM BillingEmployeeRate WHERE BillingRate<150);

10. For all clients currently in the CQR system, display details about the clients and those with sector records and those without sector records:

  • for each client with sectors: display the string 'With sectors', the client number, client first name concatenated with the client last name, and the total number of sectors the client is involved in, and
  • for each client without sector records: display the string 'Without sectors', the client number, client first name concatenated with the client last name, and the total number of sectors as a string of ‘Not applicable’.

SELECT 'With Sectors',c.ClientNumber,CONCAT(c.ClientFirstName,', ',c.ClientLastName) AS "Client Name",COUNT(*) AS "Total Sector Involved" FROM Client c, ClientSector cs WHERE c.ClientNumber=cs.ClientNumber GROUP BY cs.SectorID

UNION ALL

SELECT DISTINCT 'Without Sectors',c.ClientNumber,CONCAT(c.ClientFirstName,', ',c.ClientLastName) AS "Client Name",'Not Applicable' AS "Total Sector Involved" FROM Client c WHERE c.ClientNumber NOT IN (SELECT ClientNumber FROM ClientSector csec,Sector s WHERE s.SectorID=csec.SectorID);

OR

Getting nightmare regarding pending chemistry assignment? Then it is high time you consider hiring chemistry assignment help service of MyAssigemnthelp.com. We at MyAssignmenthelp.com deliver quality subject specific assistance on more than 100+ subjects. For us, students' need is foremost, and we work round the clock to offer science, humanities and commerce assignment help. Among Commerce wing, our one of the most popular services is capital budgeting assignment help. In science segment, we have gained popularity with biology assignment help.

Most Downloaded Sample of Management

271 Download1 Pages 48 Words

Toulin Method Of Argumentation

You are required to write a researched argument essay that convinces persuades the reader of your position / stance. This is an academic, researched and referenced do...

Read More Tags: Australia Arlington Management Management University of New South Wales Management 
202 Download9 Pages 2,237 Words

Consumer Behavior Assignment

Executive Summary The purpose of this report is to elaborate the factors which are considered by individuals before selecting an occupation. Choosing an occupati...

Read More Tags: Australia Arlington Management Management University of New South Wales Management 
367 Download13 Pages 3,112 Words

Internet Marketing Plan For River Island

Introduction With the increase enhancement in the field of technology, it has been considered essential by the businesses to implement such technology in their b...

Read More Tags: Australia Arlington Management Management University of New South Wales Management 
325 Download9 Pages 2,203 Words

Strategic Role Of HR In Mergers & Acquisitions

Executive Summary In a merger & acquisition, role of an HR has emerged as a very critical function. At each stage of merger and acquisition process, HR plays a s...

Read More Tags: Australia Arlington Management Management University of New South Wales Management 
353 Download7 Pages 1,521 Words

Relationship Between Knowledge Management, Organization Learning And HRM

Introduction In this competitive business environment where every business organization is trying to attract the customers of each other, it becomes essential for ...

Read More Tags: Australia Arlington Management Management University of New South Wales Management 
Next
Free plagiarismFree plagiarism check online on mobile
Have any Query?