Relationships in Aerospike
Asked Answered
E

2

6

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.

Epigrammatize answered 10/12, 2014 at 21:45 Comment(0)
S
4

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!

Struthious answered 11/12, 2014 at 21:43 Comment(0)
L
4

One way NoSQL key-value stores diverge from the relational way of thinking is that many-to-one relationships can be represented in the same table using lists and maps.

For example, if your user has several credit cards, each of which is a tuple of (card type, last 4 digits of the card, the token from the processor representing the card, billing zip code) those can be present as a list of maps. JOINs between two tables representing a many-to-one exist because an RDBMS models atomic data, where in Aerospike that data would be modeled as a complex data type.

Lathrop answered 12/12, 2014 at 20:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.