Are circular references acceptable in database?

前端 未结 8 1964
梦毁少年i
梦毁少年i 2020-12-08 09:50

When are circular references acceptable in database?

Theoretical and practical, any help is appreciated.

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 10:40

    I have seen circular references done for performance reasons. It looks ugly though, and the performance might be negligible.

    Example: some bulletin boards (I think phpBB does this) have a lastpostid in the category table that is a shortcut to the last post in the thread.

    This creates a circle, where the last post has a FK to the category table and the category table has a FK back to the last post.

    Like I said, I don't really like it, but I've seen it done.

提交回复
热议问题