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

DatabaseSystem-Model Questions

1. Create a database named 'Company' and create the Employee table with the given data types. Add a new record to the Department table and update salaries of employees in the 'Research' department with a 10% raise. Delete records from Works_on table for employees joined over 10 years ago. 2. Write SQL queries to: display employees ordered by salary; retrieve details of an employee; display employees from Colombo with first name starting with G; retrieve employees between salary ranges and in department 5; display projects with employee last name Silva; and more. 3. Create an index on Empid, modify Department table with foreign key constraints, create views to display employee details and departments with number of

Uploaded by

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

DatabaseSystem-Model Questions

1. Create a database named 'Company' and create the Employee table with the given data types. Add a new record to the Department table and update salaries of employees in the 'Research' department with a 10% raise. Delete records from Works_on table for employees joined over 10 years ago. 2. Write SQL queries to: display employees ordered by salary; retrieve details of an employee; display employees from Colombo with first name starting with G; retrieve employees between salary ranges and in department 5; display projects with employee last name Silva; and more. 3. Create an index on Empid, modify Department table with foreign key constraints, create views to display employee details and departments with number of

Uploaded by

Pera Nandam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

TERTIARY AND VOCATIONAL EDUCATION COMMISSION

COMMON WRITTEN EXAMINATION

All rights reserved.


NVQ Level 05 –Semester II

Information & Communication Technology

Database Systems 11 – Theory K72T001M02 Three Hours

Answer only 03 questions (Question 01 and 02 are COMPULSORY).

Usethe given tables below to answer your 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))

Project (Pnumber, Pname, Plocation, Dnum)

Department (Dnum, Dname, Mgr_Id, Dlocation, Total_Salary)

Works_on(Empid, Pnumber, Date_joined, Payment, Hours)

Note:

Mgr_Id denotes the Empid of the employee who manages the department

Question 01:

1. Write suitable code to create a database named ‘Company’. (3 marks)

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:

Write the SQL queries for the following.

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.

(10 x 05=50 marks)

Question 03:

1. Create an index on Empid for Employee table.


2. Write the SQL to modify the table Department with foreign key constraint stating
suitable actions to be taken for update and delete operations.
3. Create a view to display Fname, Lname, Pname and Hours.
4. Create a view to display Dname and the total number of employees (No_of_emps) who
are working for each department.
5. Write the syntax to create a user with a password. (05 x 5=25marks)

Page 2 of 3

TERTIARY AND VOCATIONAL EDUCATION COMMISSION

COMMON WRITTEN EXAMINATION


Question 04:

1. Write down three differences between stored procedures and triggers.


(6 marks)

2. Write the code to create a stored procedure named ‘award_bonus(emp_id IN NUMBER,


bonus_rate IN NUMBER)’ to provide a salary increment to the current salary with the
given bonus rate (i.e. salary = salary + salary * bonus_rate). The stored procedure
should also print a message 'Employee <emp_id> receives a bonus:<bonus amount>’.
(7 marks)

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

TERTIARY AND VOCATIONAL EDUCATION COMMISSION

COMMON WRITTEN EXAMINATION

You might also like