You are on page 1of 18

HUMAN RESOURCES INFORMATION SYSTEM

GROUP ASSIGNMENT

Submitted to:
Prof. Prerna Lal

Submitted by:
Group 6
Abinash Roy (20PGDMHR03)
Lavanyaa Dhavle (20PGDMHR18)
Rohan Shrivastava (20PGDMHR37)
Shristi Shukla (20PGDMHR45)
SQL SCRIPT

PROBLEM 1
1. Construction of the database for any one of the scenarios mentioned above.
CREATE DATABASE HRISA;
SHOW DATABASES;
USE HRISA;

create table hr_mst (


employee_no int not null primary key,
first_name varchar(100),
last_name varchar(100),
address varchar(100),
salary numeric(20,2),
doj date,
designation varchar(100),
grade varchar(100),
city varchar(50),
department varchar(100)
);

alter table hr_mst


add pin int;

alter table hr_mst


modify city varchar(60);

insert into hr_mst(


employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)
values(1,'abinash','roy','telco',90000,'2021-01-10','hrbp','a','jamshedpur','Human
Resource',831004);

insert into hr_mst(


employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)

---- 1 ----
values(2,'ram','kapoor','alok vihar',95000,'2021-01-10','Management
Trainee','a','jamshedpur','Human Resource',831005);

insert into hr_mst(


employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)
values(3,'priya','sharma','Vijay Garden',98000,'2021-01-10','Area sales
manager','a','Gujrat','Marketing',831006);

insert into hr_mst(


employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)
values(4,'riya','mukherjee','CH
Area',80000,'2021-01-10','Consultant','b','jamshedpur','Finance',831007);

insert into hr_mst(


employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)
values(5,'Kishan','kumar','Garia Hat',40000,'2021-01-10','sales
executive','c','Noida','Marketing',831008);

insert into hr_mst(


employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)
values(6,'Richa','Pandey','Jadavapur',99000,'2021-01-10','Senior HR
Manager','a','Hyderabad','Human Resource',831009);

insert into hr_mst(


employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)
values(7,'Shivam','Verma','Golpark',80000,'2021-01-10','Senior
Accountant','a','Pune','Finance',831010);

insert into hr_mst(


employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)
values(8,'ravi','Deshmukh','New Market',75000,'2020-01-17','Senior
Recruiter','a','Chennai','Human Resource',831011);

---- 2 ----
insert into hr_mst(
employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)
values(9,'ritu','ojha','ring road',30000,'2020-11-19','Analyst','d','Kochi','IT',831012);

insert into hr_mst(


employee_no,first_name,last_name,address,salary,doj,designation,grade,city,department,pi
n)
values(10,'tarsh','kumar','Plaza',30000,'2019-01-10','system engineer','d','Goa','IT',831013);

select * from hr_mst;

CREATE TABLE Attendance (


employee_no INT,
days_present INT,
hours_worked Int,
FOREIGN KEY (employee_no)
REFERENCES hr_mst(EMPLOYEE_no)
);

select * from attendance;

CREATE TABLE Performance_Appraisal(


employee_no INT,
SALARY_INCREASE INT,
FOREIGN KEY (EMPLOYEE_no)
REFERENCES hr_mst(EMPLOYEE_no)
ON DELETE CASCADE
);

select * from performance_appraisal;

select avg(salary)
from hr_mst;

---- 3 ----
select * from hr_mst
where salary >
(select avg(salary)
from hr_mst);

SELECT * FROM hr_mst


ORDER BY department, salary DESC;

select a.employee_no,a.first_name,a.salary,a.designation,a.city,
b.days_present,b.hours_worked,
c.salary_increase
from hr_mst a,attendance b,performance_appraisal c where
a.employee_no=b.employee_no and a.employee_no=c.employee_no;

---- 4 ----
ANSWERS (SCREENSHOTS)

● select * from hr_mst;

Displays all the data set of employees in hr_mst table entered manually with insert function.
Employee_no is taken as primary key and is not null .

● select * from attendance;

Displays all the data set of employees in attendance table entered by importing from an
excel file(.csv) format.
Employee_no is taken as foreign key

● select * from performance_appraisal;

---- 5 ----
Displays all the data set of employees in performance_appraisal table entered by importing
from an excel file(.csv) format.
Employee_no is taken as foreign key

● select avg(salary)
from hr_mst;

Displays the average salary of all the employees from hr_mst table

---- 6 ----
● select * from hr_mst
where salary > (select avg(salary) from hr_mst);

Displays the data of 8 employees who have their salary greater than the average salary of all
the employees

● (select * from performance_appraisal


where SALARY_INCREASE=
(select max(salary_increase)
from performance_appraisal));

Displays the employe_ number who has got the highest salary_increase

---- 7 ----
● alter table hr_mst
add pin int;
- Added a column for employee pincodes in the hr_mst table

● SELECT * FROM hr_mst


ORDER BY department, salary DESC;

With this function,we have grouped the employees basis their departments they are
working and within it we have arranged them on the basis of highest to lowest salary .

---- 8 ----
SELECT CONCAT(FIRST_NAME,' ',LAST_NAME) as Employee_Name from hr_mst;

Used concat function to display full name of the employee.(joining first name and last name)

● select a.employee_no,a.first_name,a.salary,a.designation,a.city,
B.days_present,b.hours_worked,
C.salary_increase
from hr_mst a,attendance b,performance_appraisal c where
a.employee_no=b.employee_no and a.employee_no=c.employee_no;

We have used SQL aliases to join important columns from all the 3
tables(hr_mst,attendance,performance_appraisal) by using primary key(employee_no) and

---- 9 ----
foreign key(employee_no) where we have linked their employee no, first
name,salary,city,no of days present,no of hours worked with the salary increment that they
will get

● We took employee_no as primary key for the hr_mst table and set it as foreign key in
the two tables of attendance and performance_appraisal.
● Attendance table records the number of days an employee was present in a month
and the total number of hours they worked.
● Performance_appraisal table gives the salary increase which is dependent on the
total number of hours worked which is present in the attendance table and
performance evaluation by their reporting managers along with feedback which is
not uploaded in the system as it is subjective data and not quantified.
● Hence all the three tables are interdependently related to each other

---- 10 ----
PROBLEM 2

Question 1.

Query: SELECT DISTINCT first_name


FROM actor;

Output:

---- 11 ----
Question 2.

Query: SELECT AVG(length)


FROM film;

Output:

---- 12 ----
Question 3.

Query: SELECT TITLE


FROM FILM
INNER JOIN FILM_ACTOR ON FILM_ACTOR.FILM_ID = FILM.FILM_ID
INNER JOIN ACTOR ON ACTOR.ACTOR_ID = FILM_ACTOR.ACTOR_ID
WHERE FILM_ACTOR.ACTOR_ID = (
SELECT ACTOR_ID FROM ACTOR WHERE FIRST_NAME='SCARLETT' &&
DFKFF LAST_NAME='DAMON'
)

Output:

---- 13 ----
Question 4.

Query:
SELECT FILM.FILM_ID, FILM.TITLE, STORE.STORE_ID,
INVENTORY.INVENTORY_ID
FROM INVENTORY JOIN STORE USING (STORE_ID) JOIN FILM USING
(FILM_ID)
WHERE FILM.TITLE = 'JERK PAYCHECK' AND STORE.STORE_ID = 1 ;
SELECT INVENTORY.INVENTORY_ID
FROM INVENTORY JOIN STORE USING (STORE_ID)
JOIN FILM USING (FILM_ID)
JOIN RENTAL USING (INVENTORY_ID)
WHERE FILM.TITLE = 'JERK PAYCHECK'
AND STORE.STORE_ID = 1
AND NOT EXISTS (SELECT * FROM RENTAL
WHERE RENTAL.INVENTORY_ID = INVENTORY.INVENTORY_ID
AND RENTAL.RETURN_DATE IS NULL);

Output:

---- 14 ----
Question 4.

Query:
SELECT FIRST_NAME, LAST_NAME
FROM ACTOR
WHERE LAST_NAME = 'WINSLET'
ORDER BY FIRST_NAME;

Output:

---- 15 ----
Question 5.

Query:
SELECT CATEGORY.NAME, COUNT(FILM_CATEGORY.CATEGORY_ID)
FROM FILM_CATEGORY
JOIN CATEGORY ON FILM_CATEGORY.CATEGORY_ID =
CATEGORY.CATEGORY_ID
GROUP BY FILM_CATEGORY.CATEGORY_ID
HAVING COUNT(FILM_CATEGORY.CATEGORY_ID) BETWEEN 50 AND 60
ORDER BY COUNT(FILM_CATEGORY.CATEGORY_ID) ;

Output:

---- 16 ----
Question 6.

Query:
SELECT TITLE, REPLACEMENT_COST, RENTAL_DURATION
FROM FILM
HAVING REPLACEMENT_COST < 15 AND RENTAL_DURATION > 5

Output:

---- 17 ----

You might also like