<a></a>
例 3.1. Twitter
例 3.2. Twissandra
Schema Layout
In Cassandra, the way that your data is structured is very closely tied to how how it will be retrieved. Let's start with the user ColumnFamily. The key is a user id, and the columns are the properties on the user:
Since some of the URLs on the site actually have the username, we need to be able to map from the username to the user id:
Friends and followers are keyed by the user id, and then the columns are the friend user id and follower user ids, and we store a timestamp as the value because it's interesting information to have:
Tweets are stored in a way similar to users:
The Timeline and Userline column families keep track of which tweets should appear, and in what order. To that effect, the key is the user id, the column name is a timestamp, and the column value is the tweet id:
原文出處:Netkiller 系列 手劄
本文作者:陳景峯
轉載請與作者聯系,同時請務必标明文章原始出處和作者資訊及本聲明。