Ask Question, Ask an Expert

+61-413 786 465

Ask PL-SQL Expert

Use Oracle SQL*PLUS to answer the following queries. It is recommended that you either use Notepad or similar (not Word) to initially create the queries.

A company keeps information on employees, their grades, the department they work in, the projects they work on and the time spent in hours on each project for a particular week. A project has a start date and also an end date is recorded on completion of the project. In addition information is held concerning customers - each project is sponsored by a particular customer although one customer may have several projects. Skills required for a particular project are recorded together with the skills that each employee possesses.
A Relational Database is to be set up for you to query. The schema and data files are in the Database folder (weeks 1-12) on OasisPlus. The tables in the database are shown below. The identifier attribute(s) are underlined, foreign keys are asterisked *.

Table Name              Attributes
Department             Dptno,Dname
Employee                Empno, Ename, Dptno*,Gradeno*,
Grade                     Gradeno,Gtitle,Salary
Project                    Projno, Ptitle, pstart, pfinish, Custno*,
Timesheet               Weekno,Empno*,Projno*,Hours
Customer                Custno, cname, location
Skill                        Skillno*,Sname
Skillproj                  Skillno*,Projno*
Empskill                  Empno*, Skillno*

It is essential that you draw an Entity-Relationship diagram (mapped to a relational database) showing the entities and relationships involved and use this when working out your code. Do not hand in this diagram– it is not assessed.

Further SQL

Study the Art College case above.

Use Oracle iSQL*PLUS to answer the following queries.  Please indicate which problem a particular solution refers by using comments e.g. /* problem 1 Find names…*

1) List employees (number and name) who work in the Web Design department.

2) List the employees (by name) who have recorded time on projects which are sponsored by customer Cater Allan at any time.

3) List the employees (by employee name and department name) who have the skills required for current projects for customer Butterfield.

4) Give the name of all employees who work in the same department as Ivor (not including Ivor).

5) How much has project ‘Pegasus’ cost so far? You can assume that there are 1600 working hours in a year, i.e. the cost of employing someone for one hour on a project is 1/1600th of his/her annual salary.

6) What is the total cost of and hours worked by each department for each week. The output from this query should look something like:

-------------------- ---------- ---------- -------------------------------
Accounts                      1                200           6425
Accounts                      2                120           3650

7) Which employees (by name), apart from Baz, have any skill that is required on a project which Baz has worked on? Use a self join to answer this problem.

8)  Give the names of any employees who work (or have worked) on all the projects in the database.

Triggers and stored procedures

Don’t forget to type the command ‘set serveroutput on’ before executing the code in this section. If you are forced out of SQL*PLUS don’t forget to retype this command.

a) prepare a PL/SQL block which includes a procedure get_customer which accepts a project title and returns the customer name and location for that project. The main block should call the procedure with project title Phoenix, and output the customer name and location.

b) prepare a PL/SQL block, which displays all employees’ numbers, name and grade title with their salary decreased by 15%.

c) Create a trigger ‘checkprojects’ to enforce the constraint that employees can only work on a maximum of 5 projects in any week. The trigger fires whenever this is an insert to the timesheet table and outputs an error message indicating the employee’s number and a suitable message whenever the total number of projects for a particular week exceeds 5. (Ignore the possibility that some rows in the given table may already violate this constraint.).

Use the following exs of insert to the timesheet table; showing the update when successful and unsuccessful (i.e. the constraint is violated).

INSERT INTO Timesheet VALUES (1,1,5,5);

INSERT INTO Timesheet VALUES (1,1,6,17);

For testing purposes the following commands (which set the database back to its original state) might be useful:

delete from Timesheet where weekno=1 and empno=1 and projno=5;

delete from Timesheet where weekno=1 and empno=1 and projno=6;

PL-SQL, Programming

  • Category:- PL-SQL
  • Reference No.:- M9601

Have any Question? 

Related Questions in PL-SQL

Purpose of the assessment with ulo mapping the purpose of

Purpose of the assessment (with ULO Mapping) The purpose of this assignment is to develop skills in managing data in databases and to gain understanding of data model development and implementation using a commercially a ...

Complete the following tasksin microsoft access create the

Complete the following tasks: In Microsoft Access, create the database and tables that you identified in W3 Assignment 2. In Microsoft Word, write the SQL statements to create the database and tables. Write SQL statement ...

For this assignment you will be provided a database backup

For this assignment, you will be provided a database backup for a database called FinanceDB. You will have to restore this backup to your own version of SQL Server. All of the questions in this assignment relate to the F ...

Continuing the project you have worked on in weeks 1-4 in

Continuing the project you have worked on in Weeks 1-4, in this final week, complete the following tasks: Refine your database and SQL statements by incorporating your instructor's feedback. Verify that the database comp ...

Assignment - queries functions and triggersaimthe aims of

Assignment - Queries, Functions and Triggers Aim The aims of this assignment are to: formulate SQL queries; populate an RDBMS with a real dataset, and analyse the data; design test data for testing SQL queries; create SQ ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As