1

I should make a site price comparisons in pure aerospike, then: products, combination products (a cpu related with some motherboards) and stores. ΓΉ The products should relate with the stores, for example a product is related to three stores and each store has a different price.

Aerospike can help me in this?

I thought I might make the relationship bins, but I do not know if it is a good idea suggestions to solve the problem?

user112752
  • 131
  • 1
  • 1
  • 9

1 Answers1

1

You can model many-to-one relationships that otherwise would be spread on two tables in a single aerospike set using the complex types list and map. So a combination product can have a 'components' bin which is a list of map objects, each of them a product. Or you can have 'components' be a list of product IDs then batch-read those products based on the IDs in the list.

However, you can also model many-to-many relationships in a similar way to an RDBMS, with an intersection table. You do not have JOIN, but you can perform separate queries and rely on the fact that aerospike key-value and batch operations are far faster than an RDBMS.

So for example you can have a store_products intersection table where you can keep an ID of the store and of the product. You build a secondary index on both the store ID and the product ID, and this allows you to do queries. If you're looking for all the stores carrying a certain product you do a query, then fetch the store objects from the store table. If you're looking for all the products in a store you query withe a where store_id=x and then do a batch-read for those products.

I hope this answers your question.

Ronen Botzer
  • 6,951
  • 22
  • 41
  • I would like to ask a favor, would you do me one example in golang to understand better? I tried, but some things in aerospike unfortunately I can not understand them :( – user112752 Mar 24 '15 at 15:11
  • You can ask that question at the Go forum (https://discuss.aerospike.com/c/client-libraries/go-client) or look at the documentation on GitHub (https://github.com/aerospike/aerospike-client-go) or the Go client manual on our site (http://www.aerospike.com/docs/client/go/). – Ronen Botzer Apr 01 '15 at 00:18