Cassandra/NoSQL newbie: the right way to model?

蹲街弑〆低调 提交于 2019-12-06 11:11:06

First things first, don't use super columns. See:

http://www.quora.com/Cassandra-database/Why-is-it-bad-to-use-supercolumns-in-Cassandra

Now to answer your question. The example you described is easily modeled with just a regular column family:

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
  }
}

You can see the flexible schema above in that each row has a different set of columns for describing that user.

For more info on the cassandra data model I would recommend reading over http://www.datastax.com/docs/1.0/ddl/index

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!