Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DBMS Lab Assignment

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Database Management System

LAB ASSIGNMENT Date:07/11/2022

Consider the following Database

1 Create Department Table with following columns and constraints:


Column name Type & Size Constraints
Dept_no numeric(2) primary key
Dname varchar(15) unique and not null
Location varchar(12) not null

2 Create Emp table with following columns and constraints:


Column name Type & Size Constraints
Emp_no numeric(4) primary key
Ename varchar(20) not null
Gender char(1) (M or F)
Job varchar(12) -
Mgr numeric(4) -
Hiredate date not null
Salary numeric(8) default 0
Comm numeric(8) -
Dept_no numeric(2) foreign key from dept table
3
Insert following data into Department table:

Dept_no Dname Location


10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 MARKETING BOSTON
4 Insert following data into Emp table:

E_no Ename Gender Job Mgr Hiredate Salary Comm Dept_no


7369 Smith M CLERK 7902 17-DEC-80 8000 - 20
7499 Allen F SALESMAN 7698 20-FEB-81 16000 3000 30
7521 Ward M SALESMAN 7698 22-FEB-81 12500 5000 30
7566 Jones F MANAGER 7839 02-APR-81 29750 - 20
7654 Martin M SALESMAN 7698 28-SEP-81 12500 14000 30
7698 Blake M MANAGER 7839 01-MAY-81 28500 - 30
7782 Clark M MANAGER 7839 09-JUN-81 24500 - 10
7788 Scott M ANALYST 7566 09-DEC-82 30000 - 20
7839 King M PRESIDENT - 17-NOV-81 50000 - 10
7844 Turner M SALESMAN 7698 08-SEP-81 15000 - 30
7876 Adams M CLERK 7788 12-JAN-83 11000 - 20
7900 James M CLERK 7698 03-DEC-81 95000 - 30
7902 Ford M ANALYST 7566 03-DEC-81 30000 - 20
7934 Miller F CLERK 7782 23-JAN-82 13000 - 10

Write the queries for the following using Joins


1 Display the location of SMITH.
2 List the total information of EMP table along with DNAME and Loc of all the emps Working
Under ‘ACCOUNTING’ & ‘RESEARCH’ in the asc Deptno.
3 List the Empno, Ename, Sal, Dname of all the ‘MGRS’ and ‘ANALYST’ working in New York,
Dallas with an exp more than 7 years without receiving the Comm asc order of Loc.
4 Display the Empno, Ename, Sal, Dname, Loc, Deptno, Job of all emps working at CJICAGO or
working for ACCOUNTING dept with Ann Sal>28000, but the Sal should not be=3000 or 2800
who doesn’t belongs to the Mgr and whose no is having a digit ‘7’ or ‘8’ in 3rd position in the
asc order of Deptno and desc order of job.
5 Display the total information of the emps along with Grades in the asc order.
6 List the Empno, Ename, Sal, Dname, Grade, Exp, and Ann Sal of emps working for Dept10
or20.
7 List the details of the emps whose Salaries more than the employee BLAKE.
8 List the employees whose Jobs are same as ALLEN.
9 List the employees who are senior to King.
10 List the employees who are senior to their own MGRS.
11 List the employees of Deptno 20 whose Jobs are same as Deptno10.
12 List the employees whose Jobs are same as MILLER or Sal is more than ALLEN.
13 List the employees who are senior to BLAKE working at CHICAGO & BOSTON.
14 Any jobs of deptno 10 those that are not found in deptno 20.
15 Find details of highest paid employee.
16 Find employee working under king.
17 List the employees who are senior to most recently hired employee working under king.
18 List the employees who joined in 1981 with the job same as the most senior person of the
year 1981.
19 List the employee in dept 20 whose sal is >the average sal 0f dept 10 emps.
21 List the department, details where at least two emps are working
22 List the details of the department where maximum number of emps are working.
23 List the employees whose salary is more than 3000 after giving 20% increment.
24 List the employees who are not working in sales dept.
25 List the employees whose sal is greater than his managers salary.

You might also like