0% found this document useful (0 votes)
2 views3 pages

Class Test_02

The document outlines a quiz on Database Management Systems, focusing on SQL queries and relational algebra. It includes tasks such as creating an 'employees' table, inserting data, and performing various queries related to employee salaries and departments. Additionally, it requires the use of relational algebra to find specific employee information based on given criteria.

Uploaded by

saripon.diu0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Class Test_02

The document outlines a quiz on Database Management Systems, focusing on SQL queries and relational algebra. It includes tasks such as creating an 'employees' table, inserting data, and performing various queries related to employee salaries and departments. Additionally, it requires the use of relational algebra to find specific employee information based on given criteria.

Uploaded by

saripon.diu0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Database management System

Quiz-2
ID:​ Section​ Date:
1.​ Write an SQL query to create a table named employees with the following columns:
○​ emp_id ,emp_name ,department ,salary ,hire_date,(2 Marks)

Include the necessary constraints to maintain data integrity (e.g., NOT NULL, CHECK,
and default values).

2.​ Insert the following data into the employees table:


○​ emp_id: 101, emp_name: 'John Doe', department: 'HR', salary: 5000,
hire_date: '2020-01-10'
○​ emp_id: 102, emp_name: 'Alice Smith', department: 'Finance', salary: 6000,
hire_date: '2019-07-25'
○​ emp_id: 103, emp_name: 'Bob Johnson', department: 'IT', salary: 7000,
hire_date: '2021-03-15'
○​ emp_id: 104, emp_name: 'Charlie Brown', department: 'HR', salary: 4000,
hire_date: '2018-11-05'
○​ emp_id: 105, emp_name: 'Eve Adams', department: 'Finance', salary: 8000,
hire_date: '2022-05-10'
3.​ Write an SQL query using a subquery to find the emp_name and salary of employees
who earn more than the average salary across all employees in the company.(2 Marks)
4.​ Write an SQL query to calculate the total salary expense for each department. Display
the department name along with the total salary. Only include departments where the
total salary is greater than 15,000.(2 Marks)
5.​ Write an SQL query to increase the salary of all employees in the 'HR' department by
10%. Ensure you use an appropriate SQL transaction control statement like COMMIT to
confirm the changes.(2 Marks)​
Part 2: Relational Algebra (5 Marks)

6.​ Using relational algebra, write an expression to find the names (emp_name) and hire
dates (hire_date) of employees who work in the 'Finance' or 'HR' departments and
have a salary greater than 5,000. Assume the employees relation has the following
attributes: emp_id, emp_name, department, salary, and hire_date. (3 Marks)

7.​ Using relational algebra, perform the following operations:


○​ Find the employees who are not managers by performing a set difference
operation between the employees and managers relations.
○​ Assume employees has emp_id, emp_name, and department, and
managers has emp_id for employees who are managers. (2 Marks)

You might also like