Skip to main content

Perform queries on a relational database system using SQL;

CSE2/4DBF 2017 - Assignment 2 (20%) 
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%]

Logo

Get 100% Original papers from the writing experts.

Comments

Popular posts from this blog

Starting with this provided code, add the following functionality

1.Starting with this provided code, add the following functionality: Replace hardcoded strings “Zero”, “One”, “Two”, “Three” in the ArrayList based on user typed input (use Scanner or JOptionPane classes). The user will be prompted for the String to be stored in the ArrayList and then hit enter. The user will be able to continue to add items to the ArrayList until they just hit enter without typing anything. Once the user does this (hits enter without typing anything), the program will display all of the elements of the ArrayList, both the index and String values, in a table. It will do this via a single loop making use of an iterator method. 2. Starting with this provided code, add the following functionality: Use a Try/Catch block so that the exception is caught and the program exits a bit more gracefully. Save this file as TryCatch.java. (Be sure to rename the Public Class accordingly.) Starting with the provided code again (without the Try/Catch block), fix the code so that

Josie Eskander

  Question 1: Task 1: Report Assume you are Josie Eskander. You are writing in response to techno trading P/L’s advertisement of a new laptop at 20% below normal price. You want information on brand name, availability of service and repairs, delivery times and methods of payment. Write the letter using the seven basic parts of the letter. In the opening paragraph present a clear and courteous request. Secondly write a response from techno trading giving details and proposing the sale. Provide draft of both emails in the space below. Question 2: Task 2: Report In pairs, nominate a good and a bad letter writer. Discuss the key differences. Write a good/bad letter from techno training to Alex Antonov accepting/declining his proposal to invest in the business Question 3: Task 3: Report Write a letter from techno trading p/l to a new client ‘new realities p/l’ urging them to buy techno new virtual reality software. Make a strong argument for the product. Question 4: Task 4: Report Write a l

Sandra Coke is vice president for research and development at Great Lakes Foods (GLF), a large snack food company that has approximately 1,000 employees

Chapter 2 I Trait Approach 33 CASE 2.1 Choosing a New Director of Research Sandra Coke is vice president for research and development at Great Lakes Foods (GLF), a large snack food company that has approximately 1,000 employees. As a result of a recent reorganization, Sandra must choose the new director of research. The director will report directly to Sandra and will be responsible for developing and testing new products. The research division of GLF employs about 200 people. The choice of directors is important because Sandra is receiving pressure from the president and board of GLF to improve the company's overall growth and productivity. Sandra has identified three candidates for the position. Each candidate is at the same managerial level. She is having difficulty choosing one of them because each has very strong credentials. Alexa Smith is a longtime employee of GLF who started part-time in the mailroom while in high school. After finishing school, Alexa worked in as many as