“Rebuttals”和“評論” - 兩個DB表還是一個?

[英]“Rebuttals” and “Comments” - Two DB-Tables or One?


I'm working on a project for a friend and I've come across a difficult decision. The project consists of essays, each of which can be challenged, and also commented on. The thing is this, only one person is able to challenge the essay, and then everybody else is locked out and can only comment.

我正在為一個朋友做一個項目,我遇到了一個艱難的決定。該項目由論文組成,每篇論文都可以受到挑戰,並對其進行評論。事情就是這樣,只有一個人能夠挑戰文章,然后其他人都被鎖定,只能評論。

The rebuttals can only be two responses deep, 2,000 words for the first and 500 words for the second. At that point, no more rebuttals - the rest of the discussion takes place in the comments (fixed length of n chars, unlike rebuttals) if the viewers feel the topic wasn't exhausted.

反駁只能是兩個反應,第一個是2000個單詞,第二個是500個單詞。在這一點上,沒有更多的反駁 - 其余的討論發生在評論中(n個字符的固定長度,不像反駁),如果觀眾覺得話題沒有用盡。

So I initially decided that rebuttals and comments were structurally the same thing, and I would merely add a boolean field within my comments table to indicate if the comment is_rebuttal. But I'm feeling a bit unsure about that direction.

所以我最初認為反駁和評論在結構上是一回事,我只想在我的評論表中添加一個布爾字段來表明評論是否是atbutbut。但我對這個方向感到有些不確定。

What would the collective-you suggest? Each essay can have a discussion between two people only, and both only get to speak 2 times. Very similar to comments, but separate.

你建議的集體是什么?每篇文章只能在兩個人之間進行討論,而且只能說兩次。與評論非常相似,但是分開。

3 个解决方案

#1


So I'd probably have a table for 'conversations', with fields for the essay poster's userID, the single responder (initially NULL) and probably a title or abstract. Another table would contain 'essays' with fields for the essay or rebutter's userID, the conversationID, the body of the post, and a post count to put them in order. Finally, I'd have a 'comments' table with comment posters userIDs, essayID's to link them to essay posts, commentID's to put them in thread mode (if that's apropriate) and of course the comment body.

所以我可能有一個用於'對話'的表格,其中包括論文海報的userID,單個響應者(最初為NULL)的字段,可能還有標題或摘要。另一個表格將包含“論文”,其中包含論文或反駁者的用戶ID字段,對話ID,帖子正文以及將它們按順序排列的帖子計數。最后,我有一個'評論'表,評論海報用戶ID,essayID用於鏈接到論文帖子,commentID用於將它們置於線程模式(如果這是合適的),當然還有評論正文。

#2


Well, hard to say without knowing more about the system. But I'd say, from what you write, yes, rebuttals & comments are similar and should be put into a single table.

好吧,如果不了解更多關於系統的話,很難說。但是我會說,從你寫的內容來看,是的,反駁和評論是相似的,應該放在一張表中。

My motto always is: When in doubt, use the simplest method. Which here is clearly a single table.

我的座右銘始終是:如有疑問,請使用最簡單的方法。這里顯然是一張桌子。

If later it turns out that separate tables are more useful, you can always refactor.

如果后來發現單獨的表更有用,您可以隨時重構。

#3


If comments and rebuttals have different maximum lengths, and different restrictions on how many you can have per essay, they sound like very different things to me. Your schema will be clearer if you create two tables for entities with different limitations, and establish different column and referential constraints.

如果評論和反駁有不同的最大長度,並且對每篇文章的數量有不同的限制,那對我來說聽起來就像是截然不同的事情。如果為具有不同限制的實體創建兩個表,並建立不同的列和引用約束,則您的模式將更清晰。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/06/28/72534c7cb949b92a8b1a4b8512684f47.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com