Self-referencing FK

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2025 Oct 9 17:9
Editor
Edited
Edited
2025 Oct 13 16:2
Refs
Refs

Not a bad practice

  • If ON DELETE CASCADE is used accidentally, the entire hierarchy can be deleted.
  • During Self Join, table scans could occur more than twice. (
    SQL JOIN
    )
Self Join simply accesses the same table twice with aliases, but from the engine's perspective, they are two independent relation instances.
/notebo
 
Self Join is possible without a Foreign Key, but in that case, orphaned data (children without parents) can occur, so data integrity should be ensured with a Self-Referencing Foreign Key constraint.
 

Recommendations