我目前正在开发一个基于论坛(问题/答案)的应用程序。
使用 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 可以进行这种操作吗?