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.
Aerospike can store data on any of the following types of media and combinations thereof: Dynamic Random Access Memory (DRAM). Non-volitile Memory extended (NVMe) Flash or Solid State Drive (SSD). Persistent Memory (PMEM).
An Aerospike “set” is similar to a table in a relational database. One of the big difference is that with Aerospike, you do not need to predefine a schema. Thus, sets are created dynamically and implicitly on first record insertion in set.
bin. In the Aerospike database, each record (similar to a row in a relational database) stores data using one or more bins (like columns in a relational database). The major difference between bins and RDBMS columns is that you don't need to define a schema. Each record can have multiple bins.
In order to add or remove a namespace in a cluster, you have to stop all the nodes (at this point), change the configuration on all the nodes (IMPORTANT - configuration should match on all nodes) and then restart the nodes one by one. For more details on configuration of a namespace, you should go through this page.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With