and discuss the integrity constraints violated by any of the following operations Q-1) Insert ('Robert', 'F', 'Scott', '943775543', '21-JUN- 42', '2365 Newcastle Rd, Bellaire, TX', M, 58000, '888665555', 1 ) into EMPLOYEE. insert into employee values('Robert','F','Scott','943775543','21- JUN42','2365 Newcastle Rd,Bellaire,TX','M',58000,'888665555',1); OUTPUT:-
Q-2) Insert ( '677678989', null, '40.0' ) into
WORKS_ON. insert into works_on values('677678989','',40.0); insert into works_on values('677678989','',40.0) OUTPUT:- Q-3) Insert ( '453453453', 'John', M, '12-DEC-60', 'SPOUSE' ) into DEPENDENT insert into dependent values ('453453453','John','M','12-DEC60','Spouse'); OUTPUT:-
Q-4) Delete the WORKS_ON tuples with ESSN=
'333445555'. delete from works_on where employee='333445555'; OUTPUT:-
Q-5) Modify the MGRSSN and MGRSTARTDATE of
the DEPARTMENT tuple with DNUMBER=5 to '123456789' and '01-OCT-88', respectively. update department set mgrssn='123456789',mgrstartdate='01- OCT88'where depno=5; OUTPUT:-
Alter the tables to
Q-1) Add Foreign Keys using Alter Table [if not done earlier]. ALTER TABLE department ADD CONSTRAINT m_ssn FOREIGN KEY(mgrssn) REFERENCES employee(ssn_number) ON DELETE SET NULL; ALTER TABLE employee ADD CONSTRAINT su_ssn FOREIGN KEY(supervisor_ssn) REFERENCES employee(ssn_number) ON DELETE SET NULL; ALTER TABLE employee ADD CONSTRAINT dep FOREIGN KEY(department_number) REFERENCES department(depno) ON DELETE SET NULL; ALTER TABLE project ADD CONSTRAINT det FOREIGN KEY(depno) REFERENCES department(depno) ON DELETE SET NULL; OUTPUT:-
Q-2) Drop Foreign key defined on SuperSSN and add it
using Alter table command. ALTER TABLE employee DROP CONSTRAINT su_ssn; ALTER TABLE employee ADD CONSTRAINT su_ssn FOREIGN KEY(supervisor_ssn) REFERENCES employee(ssn_number); OUTPUT:- Q-3) Make name of Project as Unique and sex of employee as not null. ALTER TABLE project ADD CONSTRAINT pnm UNIQUE(pname); ALTER TABLE employee MODIFY(sex char(1) CONSTRAINT sex NOT NULL); OUTPUT:-
Q-4) Make Address as a new type containing door no,
street, city, State, Continent. create table copy_of_employee as select * from employee; alter table copy_of_employee add door_no number(4); alter table copy_of_employee add street varchar(9); alter table copy_of_employee add city varchar(9); alter table copy_of_employee add state varchar(9); alter table copy_of_employee add continent varchar(9); OUTPUT:-
Q-5) Make salary of employee to accept real values.
alter table copy_of_employee modify salary number(7,2);