📞 0339-0387701 (WhatsApp) Contact

« Back to Database & Data Handling (NCCIA)

What happens if you insert an Employee with a ManagerID that does not exist in Employee?

A. The insert succeeds and creates a new manager automatically
B. The ManagerID becomes zero
C. The EmployeeID changes
D. The insert is rejected, because the self-referencing foreign key must match an existing EmployeeID or be NULL ✅

Correct Answer: D. The insert is rejected, because the self-referencing foreign key must match an existing EmployeeID or be NULL

Explanation

Referential integrity applies within the same table too, so a manager must already exist before a subordinate can reference them.