日期:2014-05-17  浏览次数:21082 次

Apache Cassandra Learning Step by Step (4): Data Modeling

22 Feb 2012, by Bright Zheng (IT进行时)

?

写在这章前面的几点牢骚或感慨:

1. 我发现建模是比较别扭的一件事情,尤其是你的脑子里都是RDBMS的ERD的时候;

2. 本人试图通过两者的建模过程体现思考要点,但感觉在NoSQL的建模上有点“那个”——如果不在大型项目上吃亏过或者直接受教于前辈,总感觉缺那么点味道;

3. 这篇是我写的最郁闷的一篇,而且可能后面需要无数个补丁,但管不了了,有错误才有感悟

?

?

5.?Data Modeling

Data Modeling is one of the most important things in experiencing Cassandra, especially to those who have lots of experiences with RDBMS data modeling.

?

By admiring Twissandra project, we name it as Jtwissandra as an example. If possible, I’ll try to create and implement it and share it in GitHub.

This is a simple example to showcase the NoSQL concepts by admiring the Twitter via Cassandra.

5.1.??Tranditional RDBMS Data Modeling

Following are the core Entities & Relationships if we’re modeling in RDBMS concepts.



?

Here are some pseudo codes for demonstrating the business logic/requirements:

1. Adding a new user:

USER.insert(user_id, user_name, user_password, create_timestamp);

2. Following a friend:

FRIEND.insert(user_id, followed_id, create_timestamp)

??????? as ($current_user_id, user_id, create_timestamp);

FOLLOWER.insert(user_id, follower_id, create_timestamp)

??????? as (user_id, $current_user_id, create_timestamp);

3. Tweetting:

FRIEND.insert(user_id, followed_id, create_timestamp)

???? ???as ($current_user_id, user_id, create_timestamp);

FOLLOWER.insert(user_id, follower_id, create_timestamp)

??????? as (user_id, $current_user_id, create_timestamp);