Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 834
seenickcode Avatar asked Dec 10 '14 21:12

seenickcode


People also ask

How is data stored in Aerospike?

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).

What are sets in Aerospike?

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.

What are bins in Aerospike?

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.

How do I use namespace in Aerospike?

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.


1 Answers

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!

like image 125
Meher Avatar answered Sep 23 '22 10:09

Meher