100% found this document useful (1 vote)
101 views6 pages

CPA LaboratoryActivity001

1. The document provides instructions for a database management system laboratory exercise involving creating and manipulating a table called EMPLOYEE_RECORD. 2. Students are asked to create the EMPLOYEE_RECORD table, insert sample data, add and modify columns, update and delete rows using SQL statements. 3. The exercises test skills like creating and altering tables, inserting, updating, and deleting data through a series of SQL queries provided as examples and questions.

Uploaded by

PaulAbibCamano
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
100% found this document useful (1 vote)
101 views6 pages

CPA LaboratoryActivity001

1. The document provides instructions for a database management system laboratory exercise involving creating and manipulating a table called EMPLOYEE_RECORD. 2. Students are asked to create the EMPLOYEE_RECORD table, insert sample data, add and modify columns, update and delete rows using SQL statements. 3. The exercises test skills like creating and altering tables, inserting, updating, and deleting data through a series of SQL queries provided as examples and questions.

Uploaded by

PaulAbibCamano
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/ 6

Course Code Type Course Code Here

Database Management System


Description
1
College / Department:
Quiz No. 001
Online Education
Laboratory Exercise Page 1 of 1

Direction: Copy and paste the PL/SQL code on the space provided after each questions ad explain each number
with question that requires you to answer in essay form.
1. Create a table name as: EMPLOYEE_RECORD with the following column as shown below:
ID FIRSTNAME LASTNAME EMAIL JOB_ID SALARY DEPT_ID
Number(6) Varchar(10) Varchar(10) Varchar(15) Varchar15 Number(6) Number(6)
PK NOT NULL
CREATE TABLE EMPLOYEE_RECORD
(ID NUMBER(6) PRIMARY KEY,
FIRSTNAME VARCHAR(10) NOT NULL,
LASTNAME VARCHAR(10),
EMAIL VARCHAR(15),
JOB_ID VARCHAR(15),
SALARY NUMBER(6),
DEPT_ID NUMBER(6));

2. Insert the following Data as shown in the table below:


ID FIRSTNAME LASTNAME EMAIL JOB_ID SALARY DEPT_ID
100 Steven King Sking Ad_pres 240000 10
101 Nena Kochar Nkochar Ad_vp 17000 20
102 Lex De haan Ldehaan Ad_vp 17000 50
103 Alexander Hunold Ahunold It_prog 9000 60
104 Bruce Ernst Bernst It_prog 6000 80
107 Diana Lorentz Dlorentz St_man 5800 90
124 Kevin Mourgos Kmourgos St_clerk 5800 110
141 Trina Rajs Trajs St_clerk 5800 190
142 Curtis Davias Cdavias St_clerk 5800 191
143 Randal Matos Rmatos St_man 4200 195
INSERT INTO EMPLOYEE_RECORD VALUES(100,'Steven','King','Sking','Ad_pres',240000,10);
INSERT INTO EMPLOYEE_RECORD VALUES(101,'Nena','Kochar','Nkochar','Ad_vp',17000,20);
INSERT INTO EMPLOYEE_RECORD VALUES(102,'Lex','De haan','Ldehaan','Ad_vp',17000,50);
INSERT INTO EMPLOYEE_RECORD VALUES(103,'Alexandar','Hunold','Ahunold','It_prog',9000,60);
INSERT INTO EMPLOYEE_RECORD VALUES(104,'Bruce','Ernst','Bernst','It_prog',6000,80);
INSERT INTO EMPLOYEE_RECORD VALUES(107,'Diana','Lorentz','Dlorentz','St_man',5800,90);
INSERT INTO EMPLOYEE_RECORD VALUES(124,'Kevin','Mourgos','Kmourgos','St_clerk',5800,110);
INSERT INTO EMPLOYEE_RECORD VALUES(141,'Trina','Rajs','Trajs','St_clerk',5800,190);
INSERT INTO EMPLOYEE_RECORD VALUES(142,'Curtis','Davias','Cdavias','St_clerk',5800,191);
INSERT INTO EMPLOYEE_RECORD VALUES(143,'Randal','Matos','Rmatos','St_man',4200,195);

3. Add new column name as ADDRESS data type char size 20.
ALTER TABLE EMPLOYEE_RECORD
ADD ADDRESS VARCHAR(20);

4. After you add a new column address view now the table? What happen to the addresses of all old
employees? Explain the reason why?
SELECT * FROM EMPLOYEE_RECORD;
The address of old employees is blank because the ‘ADDRESS’ attribute was not present
when the previous employee records were inserted into the ‘EMPLOYEE_RECORD’ table.

5. Add new record as shown below:


105 JULY SORIANO MSORIANO TEACHER 2600 80 BRGY.PAMBUAN GAPAN
INSERT INTO EMPLOYEE_RECORD
VALUES(105,'JULY','SORIANO','MSORIANO','TEACHER',2600,80,'BRGY.PAMBUAN GAPAN');

 Is inserting a new record in No.5 is possible? Why and why not? Explain the reason why?
The insert operation on No.5 is possible because the number of inserted values
matches the number of attributes in the ‘EMPLOYEE_RECORD’ table.

6. Add again a new record as shown below:


105 ARRIANE SALAMAT ASALAMAT TEACHER 2600 80 BRGY.MANGINO
INSERT INTO EMPLOYEE_RECORD
VALUES(105,'ARRIANE','SALAMAT','ASALAMAT','TEACHER',2600,80,'BRGY.MANGINO');

 Is inserting a new record in No.6 is possible? Why and why not? Explain the reason why?
The insert operation in No.6 is not possible because there is an existing entry
with the ID 105 in the ‘EMPLOYEE_RECORD’ table. A primary key constraint prevents
duplicate entries in a table.

7. Add again a new record as shown below:


106 RAYCHELOU VALENCIA RVALENCIA DEAN 50000 80 CANIOGAN ST. DR.
SIXTO BLDG. PASIG
INSERT INTO EMPLOYEE_RECORD
VALUES(106,'RAYCHELOU','VALENCIA','RVALENCIA','DEAN',50000,80,'CANIOGAN ST. DR.
SIXTO BLDG. PASIG');

 Is inserting a new record in No. 8 is possible? If not perform some modification on table structure in
order to insert the record of Ms. Valencia.
The insert operation in No.8 is not possible because the ‘ADDRESS’ attribute’s size
is 20 while the inserted ‘ADDRESS’ in the insert query has a size of 34. The table
must be altered in order to insert the said record.
ALTER TABLE EMPLOYEE_RECORD
MODIFY ADDRESS VARCHAR(40);

Note: For succeeding activity: make sure to view you table and study its content.
8. All employees that having a salary of 5800 should be assigned in one dept_id 90, update their
departments to 90.
UPDATE EMPLOYEE_RECORD
SET DEPT_ID = 90
WHERE SALARY = 5800;

9. Trina got married, after her leave Ms. Trina ask you to update her record in the database from RAJS to
DE LEON.
UPDATE EMPLOYEE_RECORD
SET LASTNAME = 'DE LEON'
WHERE LASTNAME = 'Rajs';

10. After serving the company for three year Randal got promoted as the newest ad_pres and with a new
salary of 250000. Update his record using one SQL only.
UPDATE EMPLOYEE_RECORD
SET JOB_ID = 'Ad_pres', SALARY = 250000
WHERE FIRSTNAME = 'Randal';
11. Since Mr. Randal replace the position of Mr. Steven, delete the record of Mr. Steven since he is no
longer connected to the company.
DELETE FROM EMPLOYEE_RECORD
WHERE FIRSTNAME = 'Steven';

12. All employees are given an additional 2% increase in their salaries. Create an SQL statement that would
change the employees’ salaries with additional 10%. Note: Use rows with the same values in order to
limit the number of query to be use.
UPDATE EMPLOYEE_RECORD SET SALARY = 17000+(17000*0.12) WHERE SALARY = 17000;
UPDATE EMPLOYEE_RECORD SET SALARY = 9000+(9000*0.12) WHERE SALARY = 9000;
UPDATE EMPLOYEE_RECORD SET SALARY = 6000+(6000*0.12) WHERE SALARY = 6000;
UPDATE EMPLOYEE_RECORD SET SALARY = 5800+(5800*0.12) WHERE SALARY = 5800;
UPDATE EMPLOYEE_RECORD SET SALARY = 250000+(250000*0.12) WHERE SALARY = 250000;
UPDATE EMPLOYEE_RECORD SET SALARY = 2600+(2600*0.12) WHERE SALARY = 2600;
UPDATE EMPLOYEE_RECORD SET SALARY = 50000+(50000*0.12) WHERE SALARY = 50000;

13. Email address is not being use, and save space you have to delete the said column.
ALTER TABLE EMPLOYEE_RECORD
DROP COLUMN EMAIL;

14. Select the table now and draw the final output after you perform the DDL and DML statements.
SELECT * FROM EMPLOYEE_RECORD;

ID FIRSTNAME LASTNAME JOB_ID SALARY DEPT_ID


---------- ---------- ---------- --------------- ---------- ----------
ADDRESS
----------------------------------------
101 Nena Kochar Ad_vp 19040 20

102 Lex De haan Ad_vp 19040 50

103 Alexandar Hunold It_prog 10080 60


ID FIRSTNAME LASTNAME JOB_ID SALARY DEPT_ID
---------- ---------- ---------- --------------- ---------- ----------
ADDRESS
----------------------------------------
104 Bruce Ernst It_prog 6720 80

107 Diana Lorentz St_man 6496 90

124 Kevin Mourgos St_clerk 6496 90

ID FIRSTNAME LASTNAME JOB_ID SALARY DEPT_ID


---------- ---------- ---------- --------------- ---------- ----------
ADDRESS
----------------------------------------
141 Trina DE LEON St_clerk 6496 90

142 Curtis Davias St_clerk 6496 90

143 Randal Matos Ad_pres 280000 195

ID FIRSTNAME LASTNAME JOB_ID SALARY DEPT_ID


---------- ---------- ---------- --------------- ---------- ----------
ADDRESS
----------------------------------------
105 JULY SORIANO TEACHER 2912 80
BRGY.PAMBUAN GAPAN

106 RAYCHELOU VALENCIA DEAN 56000 80


CANIOGAN ST. DR. SIXTO BLDG. PASIG
11 rows selected.

15. What will happen if the accidentally type DELETE * FROM EMPLOYEES without issuing WHERE
condition?
The query ‘DELETE * FROM EMPLOYEES’ will return an error because the table ‘EMPLOYEES’
does not exist in the database. The said query will not affect any data in the
database.

You might also like