Data-Base: Punjab University College of Information Technology
Data-Base: Punjab University College of Information Technology
DATA-BASE
Prepared for Miss. Hareem Aslam
By. Talha Mazhar Bitf19a024
TASK 1
Create the EMPLOYEESIT19 table based on the structure of the EMPLOYEES table. Include only the EMPLOYEE_ID,
FIRST_NAME, LAST_NAME, SALARY, and DEPARTMENT_ID columns. Name the columns in your new table ID, FIRST_NAME,
LAST_NAME, SALARY, and DEPT_ID, respectively.
FIRST_NAME varchar2(20),
LAST_NAME varchar2(20),
salary number(9,3),
dept_id number(4,0))
TASK 2
Add a table-level PRIMARY KEY constraint to the EMPLOYEESIT19 table on the ID column. The constraint should be named at
creation. Name the constraint my_emp_id_pk.
Modify the EMPLOYEESIT19 table. Add a COMMISSION column of NUMBER data type, precision 2, scale 2. Add a constraint
to the commission column that ensures that a commission value is greater than zero.
alter table EMPLOYEESIT19 add (COMMISSION number(2,2), CONSTRAINT EMPLOYEESIT19_COMMISSION_CK CHECK (COMMISSION >
0));
TASK 4
Task 5
TASK 6
Create a student table with columns (s_id, s_name, s_degreeCode, s_classCode), a degree table with colums(degreeCode,
degreeName, creditHrs), a class table with columns(classCode, capacity, roomNum). In student table, add the not null,
unique and primary-key constraint on s_id, foreign-key constraint on s_degreeCode and s_classCode. Unique, not null
constraint on roomNum.
(s_id number(6), s_name varchar2(30) NOT null, s_degreeCode number(5), s_classCode number(7), CONSTRAINT student_s_id_PK
PRIMARY KEY (s_id),
(classCode number(10), CAPACITY number(10), roomNum number(3) NOT null, CONSTRAINT class_classCode_PK PRIMARY KEY
(classCode), CONSTRAINT class_roomNum_UK UNIQUE (roomNum));
TASK 7
Add the constraint on creditHrs to accept values between 1-3 only and roomNum value to accept values below 20 only.
alter table degree add CONSTRAINT degree_creditHrs_ck CHECK (creditHrs IN(3, 5));
alter table class add CONSTRAINT class_roomNum_ck CHECK (roomNum < 30);
TASK 8
FROM user_CONSTRAINTS
FROM user_CONSTRAINTS
FROM user_CONSTRAINTS
alter table degree add constraint degree_degreeName_CK CHECK (degreeName IN ('BSCS', 'BSIT', 'BSSE'));