I am trying to design a key-value database .To learn I am trying to build a sample blogging application. I am storing created posts against an id
key : postid
value : post
Now I need to add comments to these posts , I would essentially want to to be able to retrive all comments for a particular post .I can think of two ways to do this .
create a comment id
Key : comment_id , Value : comment
Iterate over all comments and return where required postid == comment.postid ( comment would have a field called postid)
- Create the key of the form postid_commentid.
Iterate over the keys , break the key into two using the seprator and match something lik key[0]==postid
Which one would be more efficicent ?
Which one would be more scalable ? I am designing this for practice ,eventually I might want to scale out as well .
Is there any other way that I havent thought about ?