Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask DBMS Expert


Home >> DBMS

Case Study

Overview of assignment

As a new ABC Consultant assigned to the XYZ Company, you have been asked to enhance the current system to include payroll processing. Although the current employee table has monthly salary and commission columns, it does not provide any means for storing employee deductions. You will add the tables necessary to store employee deductions. Next you will create a payroll pre-calculation program that will calculate the net pay for all the employees via a batch process (a stored procedure in a package, which will call other stored procedures within the package). Although this is not a complete payroll system, the unit test results must be accurate.

Next you will create two PL/SQL blocks for inserting and deleting rows from the employee deduction table. These PL/SQL blocks will be passed information from host or bind variables and a third PL/SQL block which will assign the variables defined in SQL*Plus (e.g. employee number, dollar amount and deduction name). Since the XYZ Company wants to track changes to the employee and employee deduction tables, you will create two database triggers that will update audit tables when rows are changed or deleted.

The XYZ Company also requires a view that will display specific employee information, plus the number of deductions for an employee. This will be accomplished by creating a stored function that will count the number for deductions for an employee. This function will be invoked in the select statement for the employee view.

Task List

Setup

• Create the tables in the existing system. Data for these tables can be found in the appendix for this document. If you wish you may add addition rows to these tables.

CREATE TABLE dept (

deptno         Number(2) Primary Key,
dname         VARCHAR2(14),
loc               VARCHAR2(13));

Create table emp (

empno       NUMBER(4) Primary Key,
ename       VARCHAR2(10),
job            VARCHAR2(9),
mgr           NUMBER(4),
hiredate    DATE,
sal             NUMBER(7,2),
comm        NUMBER(7,2),
deptno       NUMBER(2));

Create table salgrade (

grade       NUMBER,
losal       NUMBER,
hisal       NUMBER);

• Create a table for deductions with three columns: deduction name (PK), Salary grade minimum, salary grade maximum. You need to populate the deduction table any way you wish. Populate the table with as many deductions as you think would be appropriate to thoroughly test your application. The salgrade min and max information will come from the salgrade table.

CREATE TABLE deductions  (

       name     VARCHAR2(30),

       salary_grade_min NUMBER(2),

       salary_grade_max NUMBER(2));

• Create a table for employee deductions with a foreign key (name) to the deduction table, a flag that indicates if the deduction is a before tax or after tax deduction, deduction (dollar) amount and another foreign key (empno) to the employee table. This table is an intersection table and the two foreign keys concatenated together will be the primary key of this table.

CREATE TABLE emp_deductions     (

      fk_deduction                    VARCHAR2(30),

      fk_empno                          NUMBER(4),

      before_or_after_flag         CHAR(1),

      deduction_amount           NUMBER(6,2));

• Create two audit tables, one for the employee table and one for the employee deduction table. These audit tables should contain a unique numeric ID (assigned via a sequence), the current date, and the user id of the person that has made the change to he employee or employee deduction table, and all the columns from the source table.

CREATE TABLE emp_audit   (

audit_uid            NUMBER(15),
change_date       DATE,
change_user       VARCHAR2(30),
action                 CHAR(1),
empno                NUMBER(4),
ename                VARCHAR2(10),
job                     VARCHAR2(9),
mgr                    NUMBER(4),
hiredate              DATE,
sal                      NUMBER(7,2),
comm                 NUMBER(7,2),
deptno               NUMBER(2));

CREATE TABLE emp_deductions_audit    (

audit_uid                       NUMBER(15),
change_date                  DATE,
change_user                  VARCHAR2(30),
action                            CHAR(1),
fk_deduction                  VARCHAR2(30),
fk_empno                      NUMBER(4),
before_or_after_flag       CHAR(1),
deduction_amount          NUMBER(6,2));

• Create two sequences that will be used to populate the audit tables with a unique identifier.

• Create a table to keep tax rates, these can be real or bogus, as long as there are at least 7 different rates ( For example, if the annual salary is 0 -10000 then a 5% tax rate, 10001 - 20000 then a 7% tax rate, etc)

CREATE TABLE tax_rates (

percent       NUMBER(3,2),
salary_min  NUMBER(8,2),
salary_max NUMBER(8,2));

Program Description

• Create two PL/SQL blocks that will insert or delete rows from the employee deduction table. Include exception processing for bad input data and verify that an employee is eligible for a deduction based upon their salary grade. Salary grade is determined by checking the salary grade table to derive the employee's salary grade. Once you know an employee's grade, then verify if the employee is eligible for the deduction (e.g. 401K) via comparing it to the minimum and maximum salary grade that is stored in the deduction table ( see definition above).

• Create two database triggers that will update the employee audit table and employee deduction audit table when rows are either changed or deleted. Use a sequence number to assign a unique identifier to each row as it is created in the audit table. Capture the user ID, date of the change or delete, and action (update or delete), plus all the fields in the before image of the row (e.g. before it is changed or deleted).

• Create a function that will count the number of deductions for an employee. Input to the function is the employee ID and it returns the count of employee deductions. If there aren't any deductions for the employee, the function returns zero. Within the view, include the employee name, number, hire date, job, dept number and the umber of deductions for the employee. Use the naming standard _v.

CREATE or REPLACE VIEW show_deduction_v AS

SELECT empno,
ename,
hiredate,
deptno,
job,
count_deductions(empno) deduction_cnt
FROM emp;

• Create a package that contains multiple stored procedures. Only one procedure will be available to external calls (in the package specifications). The other procedure will be subroutines that are called by the main procedure in the package body. It is okay to include stored functions in your package that support the procedure. The procedure will accomplish the following steps for each employee:

o Subtract the before tax deductions from the monthly salary.

o Calculate and subtract Federal Tax and State Income using the tax table that you created (see above). For more of a challenge, initially load the tax table into a PL/SQL table that resides in memory (optional). Use the same rate for Federal Income Tax (FIT) and State Income Tax (SIT).

- Exclude other taxes (e.g. SS)
- Include commission as part of the salary

o Subtract after tax deductions from the remaining monthly salary to determine the net pay.

o Use DBMS_OUTPUT to display all deductions/calculations and net pay. This will enable you to turn spool on and capture all the calculations for all employees when you execute the procedure via SQL*Plus.

Deliverables

- Listing of code for every block (function, trigger, a package with procedures, etc.) defined above.
- Unit test data for every block defined above (use the spool command).

Note: I'll check test results from the pre-calc program with a calculator. The net pay amount must be correct for full credit. Include test data dumps of every table so that I can verify your test results.

- MAKE A LIST OF DELIVERABLES AND CHECK IT TWICE. IF YOU LEAVE OUT A PIECE OF CODE OR UNIT TEST DATA, YOU WILL NOT RECEIVE FULL CREDIT.

Appendix

Insert into dept
values (10, 'ACCOUNTING', 'NEW YORK');

Insert into dept
values (20, 'RESEARCH', 'DALLAS');

Insert into dept
values (30, 'SALES', 'CHICAGO');

Insert into dept
values (40, 'OPERATIONS','BOSTON');

insert into emp
values (7369, 'SMITH', 'CLERK', 7902, '17-DEC-80', 800,NULL,20);

insert into emp
values (7499, 'ALLEN', 'SALESMAN', 7698, '20-FEB-81', 1600, 300, 30);

insert into emp
values (7521, 'WARD', 'SALESMAN', 7698, '22-FEB-81', 1250, 500, 30);

Insert into emp
values (7566, 'JONES', 'MANAGER', 7839, '02-APR-81', 2975,NULL, 20);

Insert into emp
values (7654, 'MARTIN', 'SALESMAN', 7698, '28-SEP-81', 1250, 1400, 30);

Insert into emp
values (7698, 'BLAKE', 'MANAGER', 7839, '01-MAY-81', 2850,NULL, 30);

Insert into emp
values (7782, 'CLARK', 'MANAGER', 7839, '09-JUN-81', 2450, NULL, 10);

Insert into emp
values (7788, 'SCOTT', 'ANALYST', 7566, '19-APR-87', 3000,NULL, 20);

Insert into emp
values (7839, 'KING', 'PRESIDENT',NULL , '17-NOV-81', 5000,NULL, 10);

Insert into emp
values (7844, 'TURNER', 'SALESMAN', 7698, '08-SEP-81',1500,0, 30);

Insert into emp
values (7876, 'ADAMS', 'CLERK', 7788, '23-MAY-87',1100,NULL, 20);

Insert into emp
values (7900, 'JAMES', 'CLERK', 7698, '03-DEC-81', 950,NULL, 30);

Insert into emp
values (7902, 'FORD', 'ANALYST', 7566, '03-DEC-81',3000,NULL, 20);

Insert into emp
values (7934, 'MILLER', 'CLERK', 7782, '23-JAN-82',1300, NULL, 10);

Insert into salgrade
values(1, 700, 1200);

Insert into salgrade
values (2, 1201, 1400);

Insert into salgrade
values (3, 1401, 2000);

Insert into salgrade
values (4, 2001, 3000);

Insert into salgrade
values (5, 3001, 9999);

commit;

DBMS, Programming

  • Category:- DBMS
  • Reference No.:- M91846457
  • Price:- $30

Priced at Now at $30, Verified Solution

The solution file is prepared in ms word and queries are executed in oracle which created database for ABC company consultant to assigned to the XYZ company to enhance the current system to include payroll processing. The database has current employee table which has monthly salary and commission attributes.This database is used to track the employees salary detection and payroll processing. All basic queries are executed and screen shots are attached in the solution with queries.

Have any Question?


Related Questions in DBMS

Sql injection on a searchthe way search performs its task

SQL injection on a search The way Search performs its task is by executing the following query (in a php script):          $var=stripslashes($_POST['search']);          $query = "SELECT username from lab1_login where use ...

Questionsuppose a prolog database exists that gives

Question: Suppose a Prolog database exists that gives information about states and capital cities. Some cities are big, others small. Some states are eastern, others are western. a. Write a query to find all the small ca ...

Database and information retrieval assignment - data

Database and Information Retrieval Assignment - Data Privacy Essay Task - Write an essay (aim for 750 words) that addresses issues associated with data proivacy. Use the Australian Privacy Principles - discussed in class ...

Sqlwrite a select statement that returns one column from

SQL Write a SELECT statement that returns one column from the Vendor table named Full Name. Create this column from the VendorContactFName and VendorContactLName columns. Format it as follows: last name, comma, first nam ...

Relational database exerciseyou have been assigned to a new

Relational Database Exercise: You have been assigned to a new development team. A client is requesting a relational database system to manage their present store with the anticipation of adding more stores in the future. ...

Question team project submission - submit to the unit 4

Question: Team Project Submission - Submit to the Unit 4 Group Project Area This version of the capstone project assignment is FOR GRADING this week. Submit to the group area the document containing completed Sections On ...

In this section the student is required to develop a

In this section, the student is required to develop a technical debate based on his/her understanding using available scientific literature. The answer to this question should not exceed three A4 Pages. In the traditiona ...

Question create an erd for the following scenarioa small

Question: Create an ERD for the following scenario. A small company ABC wants a database to keep track of internal company information. Â Given the following information create an ERD. The ABC Company has several departm ...

Backgrounda new training organization called abc

Background A new training organization called ABC TechTraining is opening soon and they have approached you to help design their new database. They have just completed the refurbishment of the premises and are now lookin ...

Sql transactions exercisesconsider table itemnameprice

SQL Transactions Exercises Consider table Item(name,price) where name is a key, and the following two concurrent transactions. T1: Begin Transaction; Update Item Set price = 2*price Where name = 'pencil'; Insert Into Ite ...

  • 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