Sie sind auf Seite 1von 3

KELANA JAYA STUDY CENTRE 18-5 PLAZA CCL, JALAN PERBANDARAN SS6/12 KELANA JAYA URBAN CENTRE 47301

KELANA JAYA

FINAL EXAMINATION JANUARY 2006


mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm COURSE TITLE COURSE CODE DATE/DAY TIME/DURATION : : : : DATABASE CSB2014/CSD2014 5 MAY 2006/FRIDAY 9.00 AM 11.30 AM / 2 HOURS

mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm INSTRUCTIONS TO CANDIDATES:


1. 2. 3. 4. 1. This Question Booklet consists of TWO (2) Sections, Section A and B. Answer ALL Questions in Section A and ALL Questions in Section B. Answer ALL questions in Section A and Section B in the Answer Booklet. Candidates are not allowed to bring into the examination hall/room any form of written materials or electronic gadget except for stationery that is permitted by the Invigilator. Students who are caught breaching the Examination Rules and Regulation will be charged with an academic dishonesty, and if found guilty of the offence, the maximum penalty is expulsion from the University.

(This Question Paper consists of 3 Printed Pages)

*** DO NOT OPEN THE QUESTION PAPER UNTIL YOU ARE TO LD TO DO SO ***

Database (CSB2014/CSD2014) January 2006 Final Examination

CONFIDENTIAL

SECTIONA There are SEVEN (7) questions in this part. Answer ALL questions. 1. a. What is a view?

(30 Marks)

(2 marks) b. Explain THREE (3) advantages of using a VIEW with examples. (6 marks) 2. List any TWO (2) advantages of using a database management system over the traditional file processing approach for storing and accessing data. (6 marks) What is the difference between dropping and truncating a table? (4 marks) 4. How is a PRIMARY KEY constraint different from a UNIQUE constraint? (2 marks) 5. What is the advantage of using a %TYPE method of declaring a variable in PL/SQL? (5 marks)

3.

6. What is the difference between CHAR and VARCHAR2 datatype in Oracle?


(2 marks)

7. What are the types of numbers that can be stored in each of the following datatype declarations?
a. b. c. NUMBER(5) NUMBER(5,2) NUMBER (3 marks)

SECTION B There is ONE (1) question in this section. Answer ALL questions. 1. Consider the following two tables: EMP TABLE Column Name EMPNO ENAME JOB MGR SAL COMM DEPTNO DataType NUMBER(4) VARCHAR2(20) CHAR(10) NUMBER(4) NUMBER(9,2) NUMBER(7,2) NUMBER(2)

(70 Marks)

Constraint PRIMARY KEY NOT NUL REFERENCES EMPNO

REFERENCES DEPT(DEPTNO)

DEPT TABLE Column Name DEPTNO DNAME LOC DataType NUMBER(2) VARCHAR2(20) VARCHAR2(20) Constraint PRIMARY KEY NOT NULL

Write the SQL commands to do the following:

Database (CSB2014/CSD2014) January 2006 Final Examination

CONFIDENTIAL

a.

Create the above two tables (along with the appropriate constraints). (6 marks)

b.

Select the employee number, employee name, job, department number and departme nt name of th all employees who have joined the organization before 30 September 1981. (5 marks) Create a new table named DESIGNATIONS which contains only the empno, ename and job columns of the original emp table. (3 marks) Insert all rows in table designation from table emp for which the department number is either 10, 20 or 30. (3 marks) Give a salary increment of 20% to all the employees in department number 20. (4 marks)

c.

d.

e.

f.

List the employee name, salary, PF, HRA, DA and gross; order the result in ascending order of gross. PF is 10% of salary, HRA is 50% of salary , DA is 30% of salary and gross = sal + HRA PF DA. (3 marks) Create a read-only view named MANAGERS of all employees who are managers . (3 marks)

g.

h.

For each department, list the number of people having the same designation. (4 marks)

i.

List the total salary, maximum and minimum salary and the average salary of employees job wise for department number 10 and 20. (5 marks) List all the employee names and their managers. (5 marks)

j.

k.

List the name of the employee drawing the highest salary. (4 marks)

l.

List the job with highest average salary. (5 marks)

m. Update the salary of all employees to the maximum salary in the corresponding department. (5 marks) n. Delete the records of employees whose salary is below the average salary in the department. (5 marks) Write a PL/SQL procedure to delete an employee from the EMP table. The steps of the procedure are as follows: a. The employee number is passed to the procedure as a parameter. b. The employee number and name of the employee in the deleted record are saved in another table called FORMER_EMP. c. The record is deleted from the EMP table. d. The delete_date column in the FORMER_EMP table is updated with the current system date. (10 marks) *** END OF QUESTION PAPER ***

o.

Das könnte Ihnen auch gefallen