Answer: Cascading Delete
Find a detailed explanation about using referential integrity constraints.
Solution
The solution is given below:
Code explanation
The explanation of the solution code is given below:
Line 2: This retrieves all the values from the
Skillstable.Lines 4–7: The
ALTER TABLEstatement alters theSkillstable to add aFOREIGN KEYconstraint namedFK_EmpID. It linksEmpIDinSkillstoEmpIDinEmployees, withON DELETE CASCADEto remove associated skills if an employee is deleted.Lines 9–10: This deletes the employee with
EmpID = 3from theEmployeestable.Line 12: This retrieves all the values from the
Skillstable again, reflecting the changes after the employee deletion.
Recalling relevant concepts
We have ...