Reputation: 1
I got a doubt while designing data model in cassandra.
i.e. I have created this CF
Page-Followers{ "page-id" : { "user-id" : "time" } }
I want to make 2 queries on the above CF.
1) To get all user-ids (as an array using multiget function of phpcassa) who are following a particular page.
2) To chech whether a particular user is following a particular page or not.
i.e. An user with user-id = 1111 is following a page page-id=100 or not.
So, how can i make those queries based on that CF.
Note : I don't want to create a new CF for this situation.Because for this user action(i.e. user clicks on follow button on a page), have to insert data in 3 CFs and if i created another CF for this, then have to insert data into total 4 CF. It may cause performance issue.
If you give example in phpcassa, then it would be great...
Another doubts is:-
As I have created cassandra data model for my college social netwoeking site(i.e. page-followers, user-followers, notifications, Alerts,...etc).
For each user action, i have to insert data into 2 or 3 or more CFs, So Is it cause for performance issue??? Is it a good design??
Please help me...
Thanks in advance
Upvotes: 0
Views: 401
Reputation: 239
In general, while data modeling in Cassandra, you first look at your queries and then construct a data model suitable for that.
For your case, you can do the following(I have no experience with phpcassa, so i can only give you the approach, you have to figure out the phpcassa bit)
1) Do a slice query with start column as '' and end column as '' and set range to a very large value. This will return you all the columns.
2) Just do a get column for rowkey = 100 and userid = 1111. If the value is not null, the user follows the page.
Cassandra is highly optimized for writes. The recommended way to model data using Cassandra is to write in denormalized fashion, even to multiple CFs. Writing to 2 or 3 families should not be an issue. You can always make the writes asynchronous to achieve better performance.
EDIT: http://thobbs.github.com/phpcassa/tutorial.html is a good place for phpcassa.
Upvotes: 1