# Best way to store bins with multiple values for one key in Aerospike

**URL:** https://discuss.aerospike.com/t/best-way-to-store-bins-with-multiple-values-for-one-key-in-aerospike/1823
**Category:** Data Modeling
**Created:** [September 10, 2015, 4:11pm UTC](https://discuss.aerospike.com/t/best-way-to-store-bins-with-multiple-values-for-one-key-in-aerospike/1823 "2015-09-10T16:11:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Hafsa](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@Hafsa](https://discuss.aerospike.com/u/Hafsa)
#### Post date: [September 10, 2015, 4:11pm UTC](https://discuss.aerospike.com/t/best-way-to-store-bins-with-multiple-values-for-one-key-in-aerospike/1823/1 "2015-09-10T16:11:38Z")

</div>

I need to save the following format in Aerospike:

```
{"name": "interest",
"datamap" : [
  {"sports":"soccer"},
  {"color":"green"}],
"clientId":"100",
"eventTagId": 78932
}

```

Here `clientId` is a key. I can save `name: interest` for a single key(`clientId`) as ‘name’ will be the bin name and ‘interest’ will be its value. But, if I have a bin with multiple values for a single key like the following example:

```
datamap" : [
      {"sports":"soccer"},
      {"color":"green"}]

```

so how to store in Aerospike? I need a solution which does not give me hard time when I have to retrieve millions of records. I was thinking in a way to create another set for `datamap` with `clientId` as a key, and later perform JOIN operation on them. But I think it is an old relational DB solution. Your suggestions will be highly appreciated.

---

<div class="post-metadata">

### Author: ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)
#### Post date: [September 10, 2015, 9:18pm UTC](https://discuss.aerospike.com/t/best-way-to-store-bins-with-multiple-values-for-one-key-in-aerospike/1823/2 "2015-09-10T21:18:09Z")

</div>

If that’s your data model I’d save it in a single record with the bins _name_, _datamap_, _clientId_, and _eventTagId_. Aerospike supports the [complex data types](https://www.aerospike.com/docs/guide/data-types.html#complex-data-types) list and map, and the data of _datamap_ is a map.

For example, this is how you do it in the Python client: [http://www.aerospike.com/docs/client/python/usage/kvs/write.html](http://www.aerospike.com/docs/client/python/usage/kvs/write.html)

Because this isn’t SQL-land, your data doesn’t need to be two-dimensional with a join connecting two tables in a many-to-one relationship. You just put complex data in the bin of your record, no JOIN needed.
