【发布时间】:2013-12-11 12:04:59
【问题描述】:
我有以下帖子架构。每个帖子都有一个嵌入式作者和附件(链接/视频/照片等数组)。
{
"content": "Pixable tempts Everpix users with quick-import tool for photos ahead of December 15 closure http:\/\/t.co\/tbsSrVYneK by @psawers",
"author": {
"username": "TheNextWeb",
"id": "10876852",
"name": "The Next Web",
"photo": "https:\/\/pbs.twimg.com\/profile_images\/378800000147133877\/895fa7d3daeed8d32b7c089d9b3e976e_bigger.png",
"url": "https:\/\/twitter.com\/account\/redirect_by_id?id=10876852",
"description": "",
"serviceName": "twitter"
},
"attachments": [
{
"title": "Pixable tempts Everpix users with quick-import tool for photos ahead of December 15 closure",
"description": "Pixable, the SingTel-owned company that organizes your social photos in smart ways, has announced a quick-import tool for Everpix users following the company's decision to close ...",
"url": "http:\/\/t.co\/tbsSrVYneK",
"type": "link",
"photo": "http:\/\/cdn1.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2013\/09\/camera1-.jpg"
}
]
}
经常阅读帖子(我们有一个包含 4 个选项卡的视图,每个选项卡需要显示 24 个帖子)。目前我们在 Redis 中对这些列表进行索引,因此查询 4x24posts 就像从 Redis 获取列表(返回 mongo id 列表)并使用 id 查询帖子一样简单。
嵌入作者的更新很少发生(例如当作者更改他的图片时)。更新不必是即时的甚至是快速的。
我们想知道是否应该将作者和帖子分成两个不同的集合。因此,帖子将引用其作者,而不是嵌入/重复的作者。这里是否首选规范化数据状态(每个帖子都重复作者,导致大量重复数据/额外字节)?还是我们应该继续去规范化状态?
【问题讨论】:
标签: mongodb database-design redis denormalized nosql