我目前正在开发一个基于问答形式的论坛应用程序。
使用C# ASP.net MVC和MongoDB进行数据存储。
我目前正在研究模型。
我想将其分为以下不同的类(简化):
public class Question
{
public string ID { get; set; }
public string Title { get; set; }
public string Body { get; set; }
public List<string> Tags { get; set; }
public DateTime DateCreated { get; set; }
public string ForumID { get; set; }
}
回答
public class Answer
{
public string ID { get; set; }
public string QuestionID { get; set; }
public string Body { get; set; }
public DateTime DateCreated { get; set; }
}
我有一个问题:
如何处理“回复”?
像上面的模型一样,我最好有两个单独的“实体”,还是应该在我的问题模型中有一个答案列表?
一些要求是我需要能够显示答案数量等...
由于这些内容存储在NoSQL数据库中,我知道我应该去正规化它们,但是我如何插入一个答案,而不检索整个帖子?使用NoRM和MongoDB可以进行这种操作吗?