RECENT ASSIGNMENT

Tweet Share WhatsApp Share
GET ANSWERS / LIVE CHAT


CSE2/4DBF 2017 - Assignment 2 (20%)
Due date: 10.00am Wednesday, 24 May 2017
AIMS AND OBJECTIVES:
? to perform queries on a relational database system using SQL;
? to demonstrate an advanced knowledge of stored procedures, stored functions and triggers.
This is an individual Assignment. You are not permitted to work as a group when writing this assignment.
Copying, Plagiarism: Plagiarism is the submission of somebody else’s work in a manner that gives the impression that the work is your own. The Department of Computer Science and Information Technology (CSIT) treats plagiarism very seriously. When it is detected, penalties are strictly imposed. Students are referred to the CSIT Handbook and policy documents with regard to plagiarism and assignment return, and also to the section of ‘Academic Integrity’ on the subject learning guide.
No extensions will be given: Penalties are applied to late assignments (5% of total assignment mark given is deducted per day, accepted up to 5 days after the due date only). If there are circumstances that prevent the assignment being submitted on time, an application for special consideration may be made. See Student Handbook for details. Note that delays caused by computer downtime cannot be accepted as a valid reason for a late submission without penalty. Students must plan their work to allow for both scheduled and unscheduled downtime.
SUBMISSION GUIDELINES:
Task 1 should be saved to a file named task1.txt using the SPOOL command.
Task 2 should be saved to a file named task2.txt using the SPOOL command. Task 3 should be saved to a file named task3.txt using the SPOOL command.
Note: an example of using the SPOOL command is given in the lab book. In the SPOOL file, you need to provide the query/procedure/function/trigger execution and the sample output. For the trigger, you need to show a sample test that demonstrates the successful execution of the trigger.
All the tasks above are to be submitted in hard-copy format to the relevant submission box on the first floor of the Beth Gleeson Building by 10.00am Wednesday, 24 May 2017. The same tasks above are also required to be submitted online via the Assignment Submission on the LMS by 10.00am Wednesday, 24 May 2017.
SUBMISSION CHECKLIST:
? The relevant SQL queries for the ‘ServiceMatch’ Database System; ? The required stored procedures, stored function, and triggers.
NOTE: No built-in ORACLE column numbering (such as ROWNUM) or other Oracle ranking facilities (such as RANK) can be used here.
Implement the following tasks using ORACLE SQL*Plus.
Download the file SMatchSchema.sql from the LMS site and run it on ORACLE SQL*Plus. This file contains all the CREATE and INSERT statements you will need for this assignment.
To run the file, issue the following command: @D:dbfSMatchSchema.sql
? Where D:dbf is the location of the file (for example).
NOTE: YOU DO NOT NEED TO INSERT MORE DATA INTO THE TABLES.
The list of tables available for this assignment is the following:
CLIENT (ClientNo, ClientName, ClientAddress, ClientPhone, ClientEmail)
CORPORATE_CLIENT (ClientNo, CorporationName, BusinessArea)
INDIVIDUAL_CLIENT (ClientNo, PropertyOwner)
BUSINESS (ABNNumber, BusinessName, ContactName, ContactNumber, ContactEmail,
BusinessAddress)
FREELANCER_BUSINESS (ABNNumber, EliteMemberID)
CORPORATE_BUSINESS (ABNNumber)
JOB (JobID, JobDescription, UrgencyLevel, JobAddress, Postcode, SelectedBusinessABNNumber,
IndustryID)
CONTRACT_JOB (JobID, StartDate, EndDate, CorporateClientNo)
CASUAL_JOB (JobID, IndividualClientNo)
EQUIPMENT (EquipmentID, EquipmentName, EquipmentStatus, EFlag, MFlag, InspectionDate)
INDUSTRY (IndustryID, IndustryTitle, UnionID)
TRADE_UNION (UnionID, UnionTitle, UnionContactName, UnionContactNumber, UnionEmail,
UnionAddress, EliteMemberID)
SUBURB (Postcode, SuburbName)
INVOICE (InvoiceNo, Amount, JobID)
REVIEW (ReviewID, ReviewDate, ReviewRating, ReviewText, JobID)
SEMINAR (SeminarID, SeminarTitle, SeminarDataTime, SeminarVenue)
EQUIPMENT_HIRE (ClientNo, EquipmentID, PickUpDate, DropOffDate)
QUOTATION (JobID, ABNNumber, QuoteAmount, QuoteStatus)
BUSINESS_INDUSTRY (ABNNumber, IndustryID)
ADJACENT_SUBURB (PostCode, AdjacentPostCode)
ELITE_MEMBER (EliteMemberID)
SEMINAR_ATTENDIES (EliteMemberID, SeminarID)
NOTE: PK is printed underlined and FK is printed italic in italics.
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.
[10 marks each – 20%]



GET ANSWERS / LIVE CHAT