正如标题所说,我对Noss DBS(如Cassandra)是公平的(完全阅读)。和其他许多人一样,我之前学过RMDBS。所以我做了一点关于' WTF是一个超级专栏'和其他明显的谷歌点击,但我仍然不知道如何模拟这个:
假设我想保存用户,如用户名/密码/名称/等等...如果该用户喜欢,移动电话和固定电话怎么办?这是对的'这样做的方法? (使用与其他网站上看到的相同的缩写JSON样式)
Users: { // <-- this is the Users SuperColumnFamily, keyed by username
myuser: { // <-- this is a User SuperColumn
username = "myuser", // <-- this is the username Column
email = "myuser@googlemail.com",
...
},
...
}
Phone: { // <-- this is where the users phone numbers are stored
myuser: {
mobile = "0129386835235",
landline = "123876912384",
},
...
}
意见/更正
答案 0 :(得分:4)
首先,不要使用超级列。参见:
http://www.quora.com/Cassandra-database/Why-is-it-bad-to-use-supercolumns-in-Cassandra
现在回答你的问题。您描述的示例很容易使用常规列族进行建模:
Users: { <- This is the name of the column family
username1: { <- this is a row key within the column family, it is one of your usernames
email: user@email.com <- these are all of the columns within this row, they correspond to attributes for this user
mobile: ...
landline: ...
}
username2: { <- another row for a different user
email: diff@email.com
}
}
您可以在上面看到灵活的架构,因为每一行都有一组不同的列用于描述该用户。
有关cassandra数据模型的更多信息,我建议您阅读http://www.datastax.com/docs/1.0/ddl/index