Ask Question, Ask an Expert


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

Writing sql statements1 for each movie category show the

Writing SQL statements. 1. For each movie category, show the number of movies in the database of that category, the total number (sum) of nominations (NOMS) and the average length of that type. Include only those categor ...

Assignment- relational database design amp

Assignment- Relational Database Design & Implementation Important Note: You are required to submit an electronic copy to ilearn as well as a hard copy of your assignment to the assignment box allocated in the ground floo ...

Question 1 create a package deptpkg with the followinga a

Question : 1. Create a package, DEPT_PKG, with the following: a) A public procedure called NEW_DEPT to enter a new department row into the DEPARTMENTS table. The procedure should accept four parameters - one for each col ...

Database assignment 11 using heritage data release 1 in

Database Assignment 1: 1. Using heritage data (release 1) in SQL a. Find support for all single itemsets b. List all itemsets with 2 elements and support of at least 0.2 c. List all itemsets with 3 elements and support a ...

Structured query language sqlrefer to the database design

Structured Query Language (SQL) Refer to the database design crested in Lab 2: Modifying a Database Design to complete this Lab. Perform the following steps in MySQL: 1. Create the tables and relationships from the datab ...

Assignmentthe following data model is designed to hold

Assignment The following data model is designed to hold information relating to Students, Student Courses and Tutors who deal with these students. For this scenario we need to define the following facts: The Entities req ...

Consider a typical sales invoice that would include the

Consider a typical sales invoice that would include the following information. Design a single table to hold all of the information required to store an invoice including this information. Next, apply normalization to re ...

Assignmentwrite sql queries for the books database

Assignment Write SQL queries for the books database (discussed in Section 18.3) that perform each of the following tasks: a) Select all authors from the Authors table with the columns in the order lastName, firstName and ...

Movie theater database sql commandswrite the sql data

Movie Theater Database: SQL Commands Write the SQL Data Definition Language (DDL) commands to create the movie theater database based upon the below Entity Relationship Model (ERM). Be sure to include commands to create ...

Sql assignmentwrite 10 sql statements against the student

SQL Assignment Write 10 SQL statements against the STUDENT schema you created for practice lab 1. Your statements should run error-free and should be valid. Submit two separate files: one plain text file (.txt or .sql fi ...

  • 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

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen