# How Design my business to elastic indexes

**URL:** https://discuss.elastic.co/t/how-design-my-business-to-elastic-indexes/147444
**Category:** Elasticsearch
**Created:** [September 5, 2018, 4:21pm UTC](https://discuss.elastic.co/t/how-design-my-business-to-elastic-indexes/147444 "2018-09-05T16:21:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Yasser\_Ahmed](https://avatars.discourse-cdn.com/v4/letter/y/97f17d/32.png) [@Yasser\_Ahmed](https://discuss.elastic.co/u/Yasser_Ahmed)
#### Post date: [September 5, 2018, 4:21pm UTC](https://discuss.elastic.co/t/how-design-my-business-to-elastic-indexes/147444/1 "2018-09-05T16:21:57Z")

</div>

Hi All,  
Please can you help me to how I can design my business case to elastic indexes.  
My business case : we have users that can make many transactions and for each transaction can have many products .  
In Relational Data base we have Table for users and table for users and transaction and table for transactions and products .  
We used join to select between the tables . How I can design this in elastic ?  
I suggest to create one index and contains nested objects for transaction and nested object for products .  
Please can you help me to design my business case.

---

<div class="post-metadata">

### Author: ![jaddison](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jaddison](https://discuss.elastic.co/u/jaddison)
#### Post date: [September 10, 2018, 3:39pm UTC](https://discuss.elastic.co/t/how-design-my-business-to-elastic-indexes/147444/2 "2018-09-10T15:39:20Z")

</div>

There are a couple of factor you need to consider, but first of all: don't think in "SQL terms". It's handy to visualize the relationships, but with Elasticsearch you are asked to think differently. **Instead of your data split/spread out into different topical tables, you are supposed to think of a _structured 'document'_.**

- how you structure your documents (define your field mappings) should depend on how you need to query those documents
- to take a document-centric approach, you need to **denormalize** your data

So instead of a separate entity relationship like `User` -\> `Transaction` -\> `Product`, you might just have a `transaction` document, that contains a nested `products` array of objects along with a `user` object.

- you can query to find transactions containing a given product(s)
- you can query to find transactions for a specific user

Something like:

```auto
{
  "user": {
    "id": 101,
    "name": "Frank Sinatra"
  },
  "value": 159.78,
  "currency": "USD",
  "products: [{
    "price": 14.95
    "currency": "USD"
    "count": 5,
    "name": "6' Pool Noodle"
  }, {
    "price": 34.92
    "currency": "USD"
    "count": 2,
    "name": "Rotten Zucchini"
  }]
}

```

But, as I said earlier - it largely depends on how you want to query the data.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 8, 2018, 3:39pm UTC](https://discuss.elastic.co/t/how-design-my-business-to-elastic-indexes/147444/3 "2018-10-08T15:39:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
