Employee Management System (EMS)
I.
i.
Complete the following assignment:
Create Emp and Dept tables.
The Emp table should contain the following fields:
Empno Number (4)
Ename Varchar (20)
Job Varchar (20)
Mgr Number (4)
Hiredate Date
Sal Number (10,2)
Comm Number (8,2)
Deptno Number (2)
The Dept table should contain the following fields:
Deptno Number
Dname Varchar (20)
Loc Varchar (20)
ii.
Insert four rows in Dept table and eight rows in Emp table as per the sample
data provided below.
Emp Table:
Empno
7650
Ename
JAMES
Job
MANAGER
Mgr
7652
7651
SCOTT
CLERK
7656
7652
JOHN
CLERK
7653
STEPHEN
CLERK
7652
7654
7655
SAM
BOB
ANALYST
ANALYST
7657
7656
WILLIAM
MANAGER
7657
7657
TOVE
CLERK
Hiredate
12-121998
11-41990
23-31997
13-32002
8-9-2005
13-52004
13-32002
8-9-2005
MySql CaseStudy
Sal
50000
Comm
1000
Deptno
30
13000
400
20
4000
300
30
3600
1200
10
23000
28000
300
700
10
20
40000
1200
30
3000
300
20
Employee Management System (EMS)
Dept Table:
Deptid
10
20
30
40
II.
i.
ii.
iii.
Dname
SALES
MARKETING
FINANCE
ADMINISTRATION
Location
DALLAS
NEW YORK
TEXAS
WASHINGTON
Complete the following assignment:
Write a query using Emp table to display the name, job code, hire date, and
employee number for each employee, such that the employee number appearing
first. Provide an alias Startdate for the Hiredate column.
From the Emp table, list the name and salary of employees who earn between
$1000 and $2500, and are in department 20 or 50. Label the columns Employee
and Monthly Salary, respectively.
From the Emp table, display the last name concatenated with the Job title in a
column and name the column Employee and Job.
Submit a document containing:
The program code and include output.
III.
Complete the following assignment:
Use Emp and Dept table and complete the following assignment:
i.
ii.
iii.
iv.
Display Empno, name, salary, and Deptno in the ascending order of employee
number using the table Emp and Dept.
Display Empno, name, salary, and Deptno in the ascending order of department
number and within department - in descending order of employee number using
the table Emp and Dept.
Display one occurrence of each job from the Emp table.
Display employee number, name, salary, and date of joining for those employees
who have joined after 28th September 1981 using the table Emp and Dept.
Submit a document containing:
The program code and include output.
IV.
Complete the following assignment:
Use table Emp and Dept and complete the following assignment:
i.
ii.
Display employee number, name, salary for those employees with salary
between 1500 and 5000, and whose name contains the string na.
Add a bonus column to your query whose value is 15% of salary for those
drawing less than a salary of 3500.
MySql CaseStudy
Employee Management System (EMS)
List the employees who draw more salary than commission.
iii.
Submit a document containing:
The program code and include output.
V.
i.
ii.
iii.
iv.
Complete the following assignment:
Create a view containing all columns except salary column from the Emp table
for Detpno 20.
Create a view on Emp table to select the Eempno, Ename, Sal, Hiredate of all
employees working in Deptno 20 with check option.
Update Deptno 20 to 30 in the view created in (ii) and observe the results.
Create a read-only view of the Emp table, containing Empno, Ename, Job,
Deptno columns.
Submit a document containing:
The program code and include output.
VI. Complete the following assignment:
Use table Emp and Dept as required and complete the following assignment:
i.
ii.
iii.
Write a query that displays the employee names and commission amounts. If an
employee does not earn any commission, then provide No Commission as the
commission amount. Label the column as COMM.
Write a query to display the number, name, and job of those employees who are
hired between 1981 and 1995.
Write a query to list out the names of the employees who have worked for more
than 20 years.
Submit a document containing:
The program code and include output.
VII.
i.
ii.
iii.
iv.
Complete the following assignment:
Write a query to find out the day of your date of birth.
Write a query using Emp and Disp table to display the total salary earned by the
employees for each job type. Display only those job types for which the total
salary exceeds 5000.
Write a query using Emp and Dept table to display the number of people with the
same job.
Write a query using Emp and Dept table to displays the employees names with
the first letter capitalized and all other letters in lowercased and length of names
for all employees whose name starts with J, A, or M. Give each column an
appropriate label. Sort the results by the employees name.
Submit a document containing:
The program code and include output.
MySql CaseStudy
Employee Management System (EMS)
VIII. Complete the following assignment:
i.
ii.
iii.
Write a query to display the employee name, department name, location of all
employees who earns commission. Use Emp and Dept table.
Write a query using Emp and Dept table to list the employee names along with
the names of the departments they are working in. The query should select the
names of those departments also, which do not have related records in Emp
table.
Write a query to retrieve the names and hiredates of the employees along with
the names and hiredates of their managers from Emp table.
Submit a document containing:
The program code and include output.
IX.
i.
ii.
iii.
Complete the following assignment:
Write a query to display the employee name, department name, location of all
employees who earns commission. Use Emp and Dept table.
Write a query using Emp and Dept table to list the employee names along with
the names of the departments they are working in. The query should select the
names of those departments also, which do not have related records in Emp
table.
Write a query to retrieve the names and hiredates of the employees along with
the names and hiredates of their managers from Emp table.
Submit a document containing:
The program code and include output.
MySql CaseStudy