Integrity constraints in employee SQL operations

December 4, 2026 · Team EasyExamNotes · 2 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-502 DBMS November 2022 solved question paper

RGPV CS-502 (GS) | November 2022 | Q3(a) | 7 marks

Question (restated): Analyze inserting a NULL employee key, deleting E3 and changing department 104 to 109 in the supplied Employee relation.

Answer

Given data

E_ID Ename dno
E1 S 101
E2 T 101
E3 R 102
E4 M NULL
E5 Y 104

Entity integrity requires every primary key to be unique and non-NULL. Referential integrity requires a non-NULL foreign key to match a referenced key. The question explicitly specifies only E_ID as the primary key, so other constraints cannot be assumed.

INSERT INTO Employee (E_ID,Ename,dno) VALUES (NULL,'T',104);
DELETE FROM Employee WHERE E_ID='E3';
UPDATE Employee SET dno=109 WHERE dno=104;

Insertion

The first statement fails because NULL is not a valid primary key. Reusing name T is not itself a violation unless Ename has a unique constraint.

Deletion

The second statement removes (E3,R,102) if no referencing foreign key prevents it. If another table references E3, the action depends on its referential rule: RESTRICT rejects the deletion, CASCADE deletes dependent rows, and SET NULL clears nullable references. If department information exists only in employee records, the last association with department 102 disappears; a separate Department table avoids this design problem.

Update

The third statement changes E5’s department to 109. With only the stated primary key, this is valid. If dno references Department, department 109 must exist or the update fails. A NULL department for E4 is permissible unless a NOT NULL constraint is declared. The original printed SQL has minor syntax inconsistencies; the statements above use valid SQL syntax.

Further reading: Silberschatz, Korth and Sudarshan, Database System Concepts.

← RGPV CS-502 DBMS November 2022 solved question paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion