【发布时间】:2017-06-04 00:43:15
【问题描述】:
我正在抓取一个新闻报纸网站。
该站点包含文章,其中包含标题、一些文本、时间戳、作者和评论部分。
评论部分包含来自不同注册用户的 cmets,他们可以在此处评论文章、为 cmets 点赞和回复其他 cmets。
我正在使用 MongoDB(初学者),我的问题是 JSON 对象中将保留什么。
例如,每篇新闻文章是否都是一个对象,其中包含所有用户 cmets。或者将每个文本/评论作为一个自己的对象是否更具可读性。
{"article": {
"id": "title of article",
"text": "text of article",
"author": "author of article",
"date": "date",
"comment_section": {
"user": "username",
"text": "text from comment",
"upvotes": int,
},
}}
或者类似的东西:
{"text": {
"text_type": "article text or comment",
"text": "text of article or comment",
"date": "date",
"author": "author of article or comment author",
"upvotes": int,
}}
第一个示例包含较少的对象,但其中包含很多内容,而后者包含很多对象,但其中包含的数据不多。
谢谢。
【问题讨论】:
标签: json mongodb database-design