0
我認爲SO和其他問題/答案系統是高級TSQL技術的完美例子。我想知道SO和其他問題/答案系統如何與數據庫表一起工作。我特別感興趣的是什麼是TSQL選擇的問題列表,你也希望顯示票數和答案。SO如何計算數據庫中的投票數,回答數和意見數?
表question
將被指定爲這
id int
title varchar
id_user int
表votes
這樣就可以監視用戶的投票特定問題
id_user int
id_question int
vote int
表 '答案' 與答覆問題
id int
id_parent int
什麼會選擇看起來像得到結果從question
喜歡這個LT:
id int
title varchar
votes_count int
answers_count int
我在想兩個方法
- 表
question
將與每一票重新計算或直接在question
表回答和更新表字段votes_count
和answers_count
。這意味着表question
會對也votes_count int, answers_count int
- 創建選擇這將加入,
votes
或answers
表直接計算count
,只是顯示question
表結果。通過選擇所有選票和答案的記錄進行計數,會損失多少速度?
謝謝。