How can i implement one-to-many relationship on Aerospike?

Yes and no. It depends on what if you are able to limit or plan how large the number of comments and size of them would be - as well as if you expect any kind of filtering or ordering on these.

It would be simple to have the user id and a map/list of their comments attached to that record - but you then need to worry about reaching the record limit if you are using a persistent storage backed namespace (not in-memory only) FAQ - Write Block Size .

Another alternative would be to write all of the comments into their own set, and have a bin you can create a secondary index on to query against.

So questions:

  • how big is each comment/related data stored with it?
  • how many comments do you expect per user (peak)?
  • how many total users do you expect (peak)?