Task 1 [50 marks]Using the tables provided above, provide SQL statements for the following queries.a. Display the most popular job type (most popular industry).b. Display the longest job in terms of contract duration.c. Suppose the manager of ServiceMatch wants to notify the businesses about a new job with job ID '11'. List businesses in the same industry for that job within surrounding geographical area. N.B: Business table has an attribute called 'BusinessPostcode'.d. List the idle clients who have not hired any equipment in the last 2 months (but hired at least once before).e. List the businesses with the highest and lowest rating from client review (List them in one table with four columns "Highest rated business”, “Highest rating out of 5", "Lowest rated business", "Lowest rating out of 5". Also, assume that there is only one highest rated business and one lowest rated business in the review table).f. Suppose hiring an equipment costs $150 per day. List down all the clients and the total expenses for each of them. The result table should have four columns: "ClientNo", "Client Name", "Total Job Expense" and "Total Equipment Hiring Expense". Also, the total expenses for a client should be zero, if he/she did not request any jobs or hire any equipment. Ignore any fine calculation and ignore the hiring cost if there is no dropOffDate.g. List down the top 2 most hired equipment (You are not allowed to use rank, top or any other keywords supporting OLAP operations).h. List down the details of those freelance businesses who do not have seminar attendance privileges.i. List the ABNNumber, BusinessName of those businesses who have placed quotes against jobs but never got contacted or selected by any client.j. List the seminar titles and date on which they were held along with the number of participations for the seminars arranged in the afternoon part of the day. (Count 1 participation for each elite member, even if the participating elite member is a trade union. Also, list the seminars with larger number of participants at the top).[5 marks each – 50%]Task 2 [30 marks]Provide the implementation of the following stored procedures and function. For submission, please include both the PL/SQL code and an execute procedure/SQL statement to demonstrate the functionality.a. Write a stored procedure that takes an industry ID as an input and lists down the representing trade union and all the registered businesses for that industry. The output should show the trade union title in one line and all the businesses' ABN and business name in different lines.b. Given the amount of overdue fine to be $20 a day. Write a stored function that takes as input a client ID and returns the total fine based on the difference between the total days of rent and maximum allowed rent duration of an equipment. Different values of fine should be generated for a particular client if the function is executed on different dates.c. Write a stored procedure that prints the total cost for equipment hire given a particular client ID along with the total fine that the client owes to ServiceMatch. Use the stored function in question b to calculate the fine amount. Also, assume it costs $150 a day to hire an equipment.[10 marks each – 30%]Task 3 [20 marks]Provide the implementation of the following triggers. For submission, please include both the PL/SQL code and an insert statement to demonstrate the trigger functionality.a. A Trigger that will restrict a client from giving a review without a job reference or for a job that is not assigned to any business yet.b. Over the time, the number of created jobs in the ServiceMatch database can grow to a size beyond maintenance. Due to this reason ServiceMatch deletes some of the old job from the job table, but still keeps some information about those jobs in a backup table called DeletedJobs. The information includes the job ID, the title of the job industry, the suburb postcode of the job and the day on which the job was deleted. Write a trigger that will insert these information on the backup table before the job is deleted.N.B: please make sure that the backup table is created first. Also, use a database sequence object to populate the primary keys for the backup table as ServiceMatch does not want JobID to be the primary key for the backup table.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here