【发布时间】:2013-07-06 07:12:40
【问题描述】:
我正在尝试了解 Cassandra 的 DB 模型,但运气不佳。几乎所有的文档都在解释 Twissandra,一个 twitter 克隆,但它实际上是一个相当简单的案例,并没有真正帮助学习如何有效地使用 Cassandra;或者它是非常基本的低级别的东西,并没有真正展示你在现实世界中通常对列/超级列所做的事情。
所以我认为论坛是一个足够复杂的应用程序,可以从中学习。假设一个网络论坛有点像 phpBB;您可以有多个论坛,每个论坛显示多个主题,每个主题都有多个帖子。
我最初想到有单独的帖子、主题和论坛列,但这似乎与我在 RDBMS 上实现的方式没有什么不同。
所以现在我想知道超级列族中的嵌套有多深。类似下面的伪模型是一种合适的建模方式吗?
Forums = {
forum001: {
name: "General News",
topics: {
topic000001: {
subject: "This is what I think",
date: "2012-08-24 10:12:13",
posts: {
post20120824.101213: { username: "tom", content: "Blah blah", datetime: "2012-08-24 10:12:13" }
post20120824.101513: { username: "dick", content: "Blah blah blah", datetime: "2012-08-24 10:15:13" }
post20120824.103213: { username: "harry", content: "Blah blah", datetime: "2012-08-24 10:32:13" }
}
},
topic000002: {
subject: "OMG Look at this",
date: "2012-08-24 10:42:13",
posts: {
post20120824.104213: { username: "tom", content: "Blah blah", datetime: "2012-08-24 10:42:13" }
post20120824.104523: { username: "dick", content: "Blah blah blah", datetime: "2012-08-24 10:45:23" }
post20120824.104821: { username: "harry", content: "Blah blah", datetime: "2012-08-24 10:48:21" }
}
}
}
},
forum002: {
name: "Specific News",
topics: {
topic000003: {
subject: "Whinge whine",
date: "2012-08-24 10:12:13",
posts: {
post20120824.101213: { username: "tom", content: "Blah blah", datetime: "2012-08-24 10:12:13" }
post20120824.101513: { username: "dick", content: "Blah blah blah", datetime: "2012-08-24 10:15:13" }
}
}
}
}
}
【问题讨论】:
-
我会首先考虑您希望如何查询数据。例如,您是想查找给定用户在特定日期范围内的所有帖子,还是要列出给定主题的所有帖子等。查询比其他任何事情都更能驱动模型。
标签: cassandra