0% found this document useful (0 votes)
28 views

Database Management Systems: Name:Bharti ROLL NO:19570073 Course:Bsc (Hons) Computer Science

This document provides the schema and queries for an EMPLOYEE-DEPARTMENT database. It defines the tables, fields, data types, constraints and sample data for the EMPLOYEE and DEPARTMENT tables. It then lists 10 queries to retrieve specific data from the tables, such as employee name, job, hire date; unique jobs; employee name and salary; and more. The queries use functions like SELECT, DISTINCT, CONCAT, WHERE and ORDER BY to filter and format the results.

Uploaded by

Sonal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Database Management Systems: Name:Bharti ROLL NO:19570073 Course:Bsc (Hons) Computer Science

This document provides the schema and queries for an EMPLOYEE-DEPARTMENT database. It defines the tables, fields, data types, constraints and sample data for the EMPLOYEE and DEPARTMENT tables. It then lists 10 queries to retrieve specific data from the tables, such as employee name, job, hire date; unique jobs; employee name and salary; and more. The queries use functions like SELECT, DISTINCT, CONCAT, WHERE and ORDER BY to filter and format the results.

Uploaded by

Sonal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

DATABASE

MANAGEMENT
SYSTEMS

NAME:BHARTI
ROLL NO:19570073
COURSE:BSC(HONS)
COMPUTER SCIENCE
*Create the following database schema EMP-DEPT
with all specified constraints and use it to answer
the given queries.

*EMPLOYEE Schema
Field Type NULL KEY DEFAULT
Eno Char(3) NO PRI NIL
Ename Varchar(50) NO NIL
Job_type Varchar(50) NO NIL
SupervisonENO Char(3) Yes FK NIL
Hire_date Date NO NIL
Dno Integer YES FK NIL
Commission Decimal(10,2) YES NIL
Salary Decimal(7,2) NO NIL

*DEPARTMENT Schema
Dno Integer No PRI NULL
Dname Varchar(50) Yes NULL
Location Varchar(50) Yes New Delhi
STEP 1:CREATE A DATABASE AND USING THE DATABASE

STEP 2:CREATING TABLE DEPARTMENT

STEP 3: INSERTING DATA IN DEPARTMENT TABLE


STEP 4:CREATING TABLE EMPLOYEE
STEP 5: INSERTING DATA IN EMPLOYEE TABLE
QUERIES
1. Query to display Employee Name, Job, Hire Date, Employee
Number; for each employee with the Employee Number
appearing first.

SELECT Eno, Ename, Job_type, Hire_date FROM employee;

2. Query to display unique Jobs from the Employee Table.

SELECT DISTINCT Job_type FROM employee;


3. Query to display the Employee Name concatenated by a Job
separated by a comma.

SELECT CONCAT(Ename, ',', Job_type) AS ‘EMPLOYEE


Name,Job’FROM employee;

4. Query to display all the data from the Employee Table.


Separate each Column by a comma and name the said column
as THE_OUTPUT.
SELECT CONCAT(Eno , ', ', Ename, ',', Job_type, ', ',SUPERVISONENO,
',' ,Hire_date, ',' ,Dno, ',' ,Commission, ',' ,Salary) AS THE_OUTPUT
FROM employee;

5. Query to display the Employee Name and Salary of all the


employees earning more than $2850.

SELECT Ename, Salary FROM employee WHERE ( Salary +


Commission ) > 2850;
6. Query to display Employee Name and Department Number
for the Employee No= 790.

SELECT Ename,Dno FROM employee WHERE Eno='790';

7. Query to display Employee Name and Salary for all


employees whose salary is not in the range of $1500 and $2850.

SELECT Ename,Salary FROM employee WHERE Salary NOT


BETWEEN 1500 AND 2850;
8. Query to display Employee Name and Department No. Of all
the employees in Dept 10 and Dept 30 in the alphabetical order
by name.
SELECT Ename,Dno FROM employee WHERE Dno=10 OR
DNO=30 ORDER BY Ename;

9. Query to display Name and Hire Date of every Employee who


was hired in 1981.

SELECT Ename,Hire_date FROM EMPLOYEE WHERE


Hire_date LIKE '1981%';
10. Query to display Name and Job of all employees who don’t
have a current Supervisor.

SELECT Ename,Job_type FROM employee WHERE


SupervisonEnoIS NULL;

THANK
YOU

You might also like