Search code examples
aerospikedb-schema

Relationships in Aerospike


I was wondering how one would represent relationships in Aerospike? I realize it's a Key-Value store but is there an example that can be given?

For example: If have a user in the system and I want to get a list of Thing records associated with that user.


Solution

  • Couple of quick ideas:

    1- Have each user be a record (equivalent of a row for conventional RDBMS) with multiple bins, each bin having the Primary Key of a 'Thing' Record in it. You can find more details about Aerospike's data model here. This should work well if the number of Things associated to a user is fairly low (under 100 typically).

    2- If you have a large number of 'Things' record associated per user, you could potentially use an LDT (Large Data Type) like an LLIST.

    Hope this helps!