Relationships in Aerospike

社会主义新天地 提交于 2019-12-22 05:23:19

问题


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.


回答1:


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!




回答2:


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.



来源:https://stackoverflow.com/questions/27411433/relationships-in-aerospike

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!