Search code examples
cassandraphpcassa

Cassandra schema for comments


I'm looking for a good way to store comments in cassandra. Can someone provide me a good Cassandra data model to store comments?

The data model should allow me to retrieve a certain number of these comments with phpcassa.

This was my idea:

Comments = {
    CommentId1:{
        CommentAuthor,
        Content,
        Timestamp
    },
    CommentId2:{
        CommentAuthor,
        Content,
        Timestamp
    }
    ...
}

CommentsLine = {
    EntryId1:{
        CommentId1: timestamp,
        CommentId2: timestamp,
        CommentId3: timestamp,
        ...
    }
    ...
}

But i'm not sure this is the better way. Thanks for helping.


Solution

  • Your solution seems to be cool but may be it's better to store in the CF CommentsLine the key with a timestamp like that you can order your comments.

    CommentsLine = {
        EntryId1:{
            timestamp: CommentId1 ,
            timestamp: CommentId2 ,
            timestamp: CommentId3 ,
            ...
        }
        ...
    }