0% found this document useful (0 votes)
2 views

Assignment-5_Constraints

The document outlines a series of SQL assignment tasks including the creation of multiple tables (dept, emp, S, P, J, SPJ) with specified attributes and constraints. It also includes instructions for inserting records, modifying constraints, and performing various delete operations on the tables. Additionally, it involves creating copies of tables and altering employee records based on specific conditions.

Uploaded by

kanz2912
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment-5_Constraints

The document outlines a series of SQL assignment tasks including the creation of multiple tables (dept, emp, S, P, J, SPJ) with specified attributes and constraints. It also includes instructions for inserting records, modifying constraints, and performing various delete operations on the tables. Additionally, it involves creating copies of tables and altering employee records based on specific conditions.

Uploaded by

kanz2912
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment-5

(Constraints in SQL)
1. Create table dept which has the following attributes (department table)
(deptno, dept_name) where deptno is primary key, dept_name in (Acc, comp, elect)
2. Create table emp which has the following attributes (employee table)
(empno, emp_name, job, sal, deptno, mgr_no) where empno is primary key, emp_name is unique,
job in (Prof, AP, and Lect), sal is NOT NULL, deptno is foreign key, mgr_no is a self-referential
foreign key.
3. Create table S which has the following attributes (Salesperson table)
(sno, sname, city) where sno is primary key
4. Create table P which has the following attributes (Part table)
(pno, pname, color) where pno is primary key
5. Create table J which has the following attributes (ProJect table)
(jno, jname, city) where jno is primary key
6. Create table SPJ which has the following attributes
(sno, pno, jno, qty) where combination of (sno, pno, jno) is a composite primary key. Also,
sno, pno, jno are foreign keys.
7. Insert at least 5 appropriate records in the above tables.
8. Drop the NOT NULL constraints from EMP table.
9. Check all the constraints name and their type of EMP table.
10. Drop the unique constraint on EMP_NAME of EMP table.
11. Drop the Foreign Key constraint on DEPTNO
12. Add Foreign Key constraint on DEPTNO as a table label constraint.
13. Drop the Check constraint from DEPT table.
14. Add COMM column in EMP table (default value 0).
15. Drop Default constraint from EMP.
16. Create duplicate copy of EMP table.
17. Copy the structure of DEPT table to a new table with different column names.
18. Copy the structure of DEPT table to a new table with different column names without any
records copied from DEPT.
19. Change the name and job of the employee whose EMPNO =100.
20. Delete the record of employee who belong to computer department.
21. Delete deptno 101 from Dept table and set NULL to the corresponding deptno in EMP table.
22. Delete deptno 102 from Dept table and its corresponding record from EMP table.
23. Delete the empno 111 who is the manager of the employee whose empno is 114.
24. Delete the record of ‘Ravi’ whose empno is 112 and set the mgr_no to NULL for all the employees
for whom Ravi is the manager.
25. Drop the duplicate table of EMP.

You might also like