DatabaseSystem-Model Questions
DatabaseSystem-Model Questions
Employee (Empid char(04), Fname varchar(10), Lname varchar(20), City varchar(75), Bdate
Date, Designation varchar(25), Date_Joined Date, Salary Number(7,2), Dnum
char(03))
Note:
Mgr_Id denotes the Empid of the employee who manages the department
Question 01:
2. Write SQL Statement to create the Employee table with the given data types (No need
to insert the records) (6 marks)
3. Write SQL Statement to add a new record to Department table with following details
Dnum- ‘025’, Dname - ‘Marketing’, Mgr_Id-–‘M324’, Dlocation - ‘Kandy’ (4 marks)
4. Update salaries of all employees in the ‘Research’ department with a 10 percent raise
in salary. (6 marks)
5. Write the code to delete the records from Works_on table with respect to the
employees who have joined the project 10 years before the current date. (6 marks)
Question 02:
1. Show all employees Fname, Lname, Designation and Salary in the ascending order of
Salary values.
2. Retrieve the birth date and address of the employee(s) whose name is ‘Kapila Dias’.
3. Show the Employee details who come from city ‘Colombo’ and whose first name starts
with ‘G’.
4. Retrieve all employees in department Number 5 whose salary is between Rs.30,000 and
Rs. 50,000.
5. Selects the project numbers and namesof projects that have an employee with last
name ‘Silva’ involved as worker.
6. For every project located in Galle, list the project number, the controlling department
name, and the department manager’s last name, city, and birth date.
7. For each project, retrieve the project number, the project name, and the number of
employees who work on that project.
8. For each project, retrieve the project number, the project name, and the number of
employees from department 5 who work on the project.
9. Show the resulting salaries if every employee working on the project named Port City is
given a 10 percent raise.
10. For each project on which more than two employees work, retrieve the project number,
the project name, and the number of employees who work on the project.
Question 03:
Page 2 of 3
3. Write the code to create a function named ‘total Employees (Dnum char(03))’ to return
the number of employees working for a given department.
(6 marks)
4. Write the code to create a trigger named ‘Total_sal1’ to update the total salary value of
the relevant department when a new employee is inserted into the Employee table.
(6 marks)
Page 3 of 3