It6202 Lab - 001

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

creatKI 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


2 (ID NUMBER(6) PRIMARY KEY,
3 FIRSTNAME VARCHAR(10) NOT NULL,
4 LASTNAME VARCHAR(10),
5 EMAIL VARCHAR(15),
6 JOB_ID VARCHAR(15),
7 SALARY NUMBER(6),
8 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,’ALEXANDER’,’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’,’110’);
INSERT INTO EMPLOYEE_RECORD VALUES
(124,’KEVIN’,’MOURGOS’,’KMOURGOS’,’ST_CLERK’,’5800’,’110’);
INSERT INTO EMPLOYEE_RECORD VALUES
(141,’TRINA’,’RAIS’,’TRAIS’,’ST_CLERK’,’5800’,’190’);
INSERT INTO EMPLOYEE_RECORD VALUES
(142,’CRUTIS’,’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?

The appearance of the address column in the table has caused some concern, as it has been
observed that the address information for a number of former employees is missing. This is due to a lack
of data input during the encoding process, which resulted in the omission of this important information
for those specific individuals. The absence of this information for the former employees raises questions
about the thoroughness of the data input process and the reliability of the information contained within
the table.

5. Add new record as shown below:inset


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

 Is inserting a new record in No.5 is possible? Why and why not? Explain the reason why?
The ability to insert a new record with number 5 is feasible because the identification number for
record number 5 is distinct from those of previous employees who have already been encoded into the
system. This uniqueness of the ID for record number 5 eliminates any potential conflicts with the
existing employee information that has already been entered and stored within the database. As a result,
the addition of this new record will not cause any disruptions to the current organization of the employee
information.

6. Add again a new record as shown below:


10 ARRIANE SALAMAT ASALAMAT TEACHER 2600 80 BRGY.MANGINO
5
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?

It would not be feasible to insert this new record into the table due to a potential conflict that
could arise with the ID numbers assigned to row no. 5 and row no. 6. These two rows in the table
have the same ID, and adding a new input with a similar ID would create confusion and make it
impossible to properly process the information. This situation requires a unique and distinguishable
ID for each record in the table, otherwise it would be difficult to properly manage and organize the
data.
7. Add again a new record as shown below:
106 RAYCHELO VALENCIA RVALENCIA DEAN 5000 80 CANIOGAN ST. DR.
U 0 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.
It is not possible to insert the new record no.8 because the content of the address exceeded to
the limited value of the column there for the content of no.8 would be rejected. The modification that
can be done in order for the database to accept this content is to reduce the amount of the address
like removing the “Caniogan St.” so that system can accept the content of Ms. Valencia.

INSERT INTO EMPLOYEE_RECORD VALUES


(106,'RAYCHELOU','VALENCIA','RVALENCIA','DEAN','50000','80','DR.SIXTO
BLDG.PASIG');

8. All employees that having a salary of 5800 should be assigned in one dept_id 90, update their
departments to 90.

SQL> UPDATE EMPLOYEE_RECORD SET DEPT_ID ='90' WHERE ID = 124;

1 row updated.

SQL> UPDATE EMPLOYEE_RECORD SET DEPT_ID='90'WHERE ID = 141;

1 row updated.

SQL> UPDATE EMPLOYEE_RECORD SET DEPT_ID='90'WHERE ID =142;

1 row updated.

9. Trina got married, after her leave Ms. Trina ask you to update her record in the database from RAJS to
DE LEON.

SQL> UPDATE EMPLOYEE_RECORD SET LASTNAME='DE LEON' WHERE ID=141;

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.

SQL> UPDATE EMPLOYEE_RECORD SET SALARY='250000' WHERE ID=143;


SQL> UPDATE EMPLOYEE_RECORD SET JOB_ID='AD_PRES' WHERE ID=143;

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.

SQL> DELETE FROM EMPLOYEE_RECORD WHERE ID=100;

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.

SQL> UPDATE EMPLOYEE_RECORD SET SALARY=SALARY+(SALARY*10/100);

11 rows updated.

13. Email address is not being use, and save space you have to delete the said column.

SQL> 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.

SQL> SELECT*FROM EMPLOYEE_RECORD;

ID FIRSTNAME LASTNAME JOB_ID SALARY DEPT_ID ADDRESS


---------- ---------- ---------- --------------- ---------- ------ ------ --------------------
101 NENA KOCHAR AD_VP 18700 20

102 LEX DE HAAN AD_VP 18700 50

103 ALEXANDER HUNOLD IT_PROG 9900 60

104 BRUCE ERNST IT_PROG 6600 80


107 DIANA LORENTZ ST_MAN 6380 110

124 KEVIN MOURGOS ST_CLERK 6380 90

141 TRINA DE LEON ST_CLERK 6380 90

142 CRUTIS DAVIAS ST_CLERK 6380 90

143 RANDAL MATOS AD_PRES 275000 195

105 JULY SORIANO TEACHER 2860 80 BRG.PAMBUAN GAPAN

106 RAYCHELOU VALENCIA DEAN 55000 80 DR.SIXTO BLDG.PASIG

11 rows selected.

15. What will happen if the accidentally type DELETE * FROM EMPLOYEES without issuing WHERE
condition?

If the name of the table associated with this sentence were entered incorrectly, it would not have
any negative effects on the database because it is associated with the correct table; however, if the name
of the table were entered correctly by chance, the entire contents of that table would be permanently
deleted, leaving only the name of the table as the only item still present in the database.

You might also like