I'm working on a system where the previous programmer has structured a certain table of posts referencing itself (to be able to identify what would be the comment of the post)
More or less like this:
Posts
-- id
-- post_id => Referencia de Post (ela mesma)
-- texto
-- usuario_id
What I had post_id would be the comments of the related post; and what I did not have was the normal post.
In this case, I already know that this structure is completely wrong, because a table called comentarios
with foreign key defined in posts
But outside of this case, there are other cases where there is a need to reference the table itself with a foreign key (I've never seen this)?