0% found this document useful (0 votes)
11 views4 pages

DB - Labtest1 - Sem 1 - 2024 - 25 - UN1 - Monday

Uploaded by

emotilenny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

DB - Labtest1 - Sem 1 - 2024 - 25 - UN1 - Monday

Uploaded by

emotilenny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

UNIVERSITY OF TECHNOLOGY, JAMAICA

Lab Test #1
DATE: November 18, 2024 DURATION: 3 HOURS

INSTRUCTIONS: MARKS WILL BE DEDCUTED FOR NOT FOLLOWING INSTRUCTIONS


Answer All questions on this paper. Upon completion save the SQL statements as DB_Labtest1_Sem1_2024-
25_ID#.sql and upload to Moodle. Please ensure your name and your id number is included as comments in
your file. DO NOT SEND AN EMAIL, IT WILL BE IGNORED ALL FILES MUST BE UPLOADED TO MOODLE BEFORE
CLOSING!!!

Scenario:
Promaneng Company Ltd is an engineering company that works on various engineering projects across the
island. They employ various person such as engineers, welders, masons, plumbers etc. to work on these
projects. Employees may be working on several projects simultaneously. However, whenever an employee is
assigned to a project, their work as to be signed off and audited by a senior employee who is the Foreman. The
company wants to track the date an employee was assigned to a project, the rate paid and date their
assignment is ended. Each project will have a name, the client who owns the project, estimated cost, estimated
time of completion, a code and location. Each employee possesses several skills in addition to their personal
details. Your job is to implement the database. The relational schema is given below:

Employee (EmpID, fName, lName, mName, address, position, email, dob, gender, employDate)
EmpSkills (EmpID, skill)
Foreign Key EmpID references Employee
Project (prjCode, location, prjEstimate, client, EstimatedDuration, prjCost, dateCompleted)
ProjectAssignment(EmpID, prjCode, rateperHr, dateAssigned, noOfDaysWorked, Foreman)
Foreign Key EmpID references Employee
Foreign Key prjCode references Project
Foreign Key Foreman references Employee

Table 1 –Project Information

Project Client Value $ Estimated Date Began Date Completed


Location millions Duration

Falmouth Hylton Hotels 60 24 months 3/10/2023

Kingston PetroOil Co. Ltd 9 6 months 1/15/2024 6/27/2024

Spanish Town National Power Inc. 16 5 months 9/8/2024

Montego Bay Petro Oil Co. Ltd 25 9 months 8/2/2023 10/8/2024

Kingston Superfed Co Ltd 13 2 months 6/1/2024 7/22/2024

1
.
Table 2: Employee information
empID Name skills EmpDate Gender Address & phone DOB Position
mm/dd/yy

1071 Kyon Brown Design, project 10/12/1999 M 12 Parkview Lane, Porous, 09/20/1970 engineer
management Manchester
876-983-2211

2345 Jugga Welding, masonry 04/28/2014 M 13 Rose Ave, May Pen, 01/31/1985 welder
Blacks Clarendon
876-955-9003

3227 Arya Stark Welding, masonry 09/27/2021 F 2 Cow Market, Spanish Town 11/22/2000 Crane
St. Catherine operator
876-984-9978

5460 Frodo Electrical, painting 06/06/1996 M 876-912-8694 06/02/1958 helper


Baggins

4129 Seong Lang Masonry, 08/21/2015 F Ocean Boulevard, Kingston 09/10/1992 helper
plumbing 876-487-1923

6578 Nigel designing 12/15/2001 M 12 Broadway, Manor Park, St. 12/4/1960 engineer
Podrick Andrew
876-554-0017

8762 Dee Syde Masonry, painting, 01/27/2022 F 3 Burke Rd, Spanish Town, 09/27/1984 helper
plumbing St. Catherine

Table 3: Employees assigned to projects

Employee Client Supervised By Date Assigned Rate per hour Date Ended
for each emp. $

Seong Lang, Hylton Hotels Nigel Podrick 3/10/2023 1260


Jugga Blacks 650

Frodo, Dee Syde Petro_Oil Co. Ltd Nigel Podrick 1/15/2024 750 & 650 7/13/2024

Arya, Frodo National Power Co Nigel Podrick 9/8/2024 990, 750

Jugga, Seong Petro Oil Co. Ltd Kyon Brown 8/2/2023 550, 1100 & 10/8/2024
Lang, Arya 1050

Jugga, Arya Superfed Co Ltd Kyon Brown 6/1/2022 $540 & $550

Task 1 - Implement the ERD shown above. (23 marks)


2
a. Create Table Statements [7]
(Ensure auto number is used for the Project table)
i. Using appropriate Foreign Keys [4]
ii. Ensure that the mandatory participation is implemented for the Foreman [2]
b. Adjust the project table by adding dateBegan [2]
c. Create and name the following constraints [2+2+2]
i. Ensure that phone number is unique
ii. The date ended for a project cannot be before the date started
iii. Rate per hour must have a default value of $500
d. No. of days an employee worked should be removed and replaced with end date [2]

Task 2 -Demonstrate interacting with data with one SQL statement (22 marks)
a. Develop appropriate full and partial insert statements for each table [8]
(Information in Tables 1 and 2 should be inserted as well as other information given)

b. Arya Stark worked on National Power Company’s project for only 26 days. Use a function to
calculate and update the date she ended her work assignment for that project.
[4]
c. There will be a special recognition ceremony in seven (7) months time for all employees who
have been with the company for at least 2 years at the time of the ceremony and for employees
who will reach retirement age at the time of the ceremony (60 years). Display the names, gender,
email and number of years of employment at the time of the Ceremony, age at time of the
ceremony for these employees. Sort the results by month of employment in ascending order
male employees first.
[5]
d. Display the client, date began, date ended, estimated duration, actual duration in months, number
of days overrun (assume 30 day months) for all projects where the project lasts longer than
expected or for those clients that is not a limited liability company (ltd).
[5]

Task 3 – Joins, Sub-queries and Views [37 marks]

a. Display the client, project location, date project began, duration of project in days, estimated cost,
employees with skills in welding or masonry that is assigned to the project showing date assigned
to the project, their gender, position and address and the name of the employee who is overseeing
the work on the project.
[8 marks]

3
b. Using a left join display the employees that have not been assigned to work on any project. Show
their full name (as one string), age, skills, gender and phone number. Sort the records by age,
female employees first.
[5]
c. Using a right join display all projects that has no employees assigned to work on it.
[5]
d. Using sub-queries and join statements, for projects that were completed (project has ended) within
the estimated time, we want to know the client, the value of the project, the employee that
supervised the other employees that worked on the project (full name, position, years of
employment) and the actual duration of the project.
[6]
e. Show the employee that was the first to join the company. Show their name, gender, years of
employment, date joined, dob, age and their skills. Ensure at least one sub-query and one IN
statement is included in your solution.
[6]
f. Create a view that shows each employee name, rate per hour, gender, Potential earnings (based on
a 40 hr work week), date of birth, age, number of years of employment for all employees assigned
to work on projects. The potential earnings are based on their duration on a project to date.
Assume a 30 day for each month and weekends not included.
[7]
Task 4: Aggregate Functions (18 marks) – Use one statement for each task

a. Calculate the average months of employment of male and female employees (Use one statement)
[4]
b. Display the total estimated cost for all projects by location having a value in excess of a
9 million dollars.
[4]
c. How many employees are supervising projects that are still ongoing?
[3]
d. Display the name, phone number and age of the youngest female employee?
[4]
e. Display duration in days of the project that took the most days to complete to date.
[3]

********************* End of Test ***********************

You might also like