Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

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:

DNAME                    WEEKNO TOTALHOURS  TOTALCOST
-------------------- ---------- ---------- -------------------------------
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

Database assignment aggregate functions nested queries

Database Assignment: Aggregate Functions, Nested Queries, Union, Intersect, Except Name__Shelly Rideout Write the SQL code for the following queries (you do not have to give the results of the query) 1. List the employee ...

Sql fundamentalsprojectwrite a script that will create the

SQL Fundamentals Project Write a script that will create the below tables with the indicated relations. Your script must build a database that contains the tables specified in the diagram. You can use any name for your d ...

Module triggersmodule overview- in this module you will

Module Triggers Module Overview - In this module you will learn how to write PL/SQL and T-SQL triggers Objectives After completing this module you will be able: - to develop, test and debug Oracle PL/SQL triggers - to de ...

The stevens company is converting from the sql server

The Stevens Company is converting from the SQL Server database to the Oracle database. Using the sample shown below, create a Risk Information Sheet for at least five potential risks that might be encountered during the ...

Using the data model shown below write sql statements as

Using the data model shown below write SQL statements as specified below. Some questions may require more than one SQL statement to get the full answer. You may make up whatever data values you like to complete the assig ...

Use mysql workbench for these questions do not use

Use MySQL Workbench for these questions. Do NOT use Lucidchart. MySQL Workbench has more capability than Lucidchart, as it allows creation of DDL SQL from the model. Turn in 1 Workbench file , 1 document with the forward ...

These exercises all use the createmyguitarshopsql links to

These exercises all use the create_my_guitar_shop.sql (Links to an external site.). Write the code for each and save the code (each code segment identified and separated) in Notepad. Submit your completed assignment via ...

The following assignment is based on the database

The following assignment is based on the database environment created Design and develop the below queries using professional principles and standards: • A set of SQL Statements that returns all rows and all data for eac ...

Case study susan the sql programmerplease assist with the

Case Study: Susan the SQL Programmer Please assist with the following. CASE EXAMPLE IS ATTACHED AS A .JPG Read the case example about Susan the SQL Programmer on page 6-1 of the Ethical Hacking and Countermeasures: Web A ...

What is sqlanswer the following question in 500 words or

What is SQL Answer the following question in 500 words or more. You MUST use two outside sources to support your answer. You MUST cite these sources in APA Format. Title page, reference page, or cited sources do not coun ...

  • 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

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate