我试图了解 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" }
}
}
}
}
}