我正在設計一個博客網站在PHP中,用戶可以添加手動相關帖子到一個帖子。如何添加手動相關的帖子到帖子?
我以爲所有相關帖子都使用自動增量整數。
這是表:
Blog:
-id
-related (it's 0 if there aren't related posts or it contain an autoincremet integer that it is the same for all posts related)
-id_user
-title
-body
-date
我不喜歡使用「相關表」如果可能的話,避免複雜的查詢。
所以我需要一種方法在這種情況下獲得一個自動遞增整數或者你可以給我建議其他的解決方案:)
沒錯,這樣的複雜性和數據冗餘實際上是減少了。 – 2013-05-10 08:18:16
所以在這種情況下,當用戶發佈,所以我需要做2個查詢(插入博客表並插入相關表)? – xRobot 2013-05-10 08:35:53
@xRobot:不,只有當您添加相關帖子時,您纔會更新'related-posts'表。它是原始表格的一個完全獨立的部分。 – 2013-05-10 08:50:48