# Best way to model documents without needing of join

**URL:** <https://discuss.elastic.co/t/best-way-to-model-documents-without-needing-of-join/197561>\
**Category:** Elasticsearch\
**Created:** [August 30, 2019, 5:25pm UTC](https://discuss.elastic.co/t/best-way-to-model-documents-without-needing-of-join/197561 "2019-08-30T17:25:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedroe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pedroe/32/53381_2.png) [@pedroe](https://discuss.elastic.co/u/pedroe)\
**Post date:** [August 30, 2019, 5:25pm UTC](https://discuss.elastic.co/t/best-way-to-model-documents-without-needing-of-join/197561/1 "2019-08-30T17:25:05Z")

</div>

I have the following model in a traditional relational database:

- `Restaurant [id, name, address, phone, etc.]`
- `RestaurantMenu [restaurant_id, menu_item_name, menu_item_price]`

In `Restaurant` I store the information about a restaurant. I can have thousands of restaurants.

In `RestaurantMenu` I store all the itens in the menu of each restaurant.  
Example:  
[joe's pizza, cheese pizza, 10,00]  
[joe's pizza, pepperoni pizza, 12,00]  
[nakiru sushi, sashimi, 20,00]  
[nakiru sushi, niguiri, 16,00]

When I'm searching for "What restaurants can I find cheese pizza?", I do "`select name from restaurant, restaurantmenu where restaurantmenu.menu_item_name like '%cheese pizza%' and restaurant.id = restaurantmenu.restaurant_id`".

How can I achieve same results with ElasticSearch? I was told I can't do joins in ES. What would be the best way to create my ES structure?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 1, 2019, 6:40pm UTC](https://discuss.elastic.co/t/best-way-to-model-documents-without-needing-of-join/197561/2 "2019-09-01T18:40:32Z")

</div>

Have you tried denormalizing the data set, putting all the data for a dish and restaurant in each document?

---

<div class="post-metadata">

**Author:** ![pedroe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pedroe/32/53381_2.png) [@pedroe](https://discuss.elastic.co/u/pedroe)\
**Post date:** [September 20, 2019, 5:29pm UTC](https://discuss.elastic.co/t/best-way-to-model-documents-without-needing-of-join/197561/3 "2019-09-20T17:29:54Z")

</div>

Thanks. Once I found the [nested datatype](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html) I understood the idea.

---

<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 18, 2019, 5:30pm UTC](https://discuss.elastic.co/t/best-way-to-model-documents-without-needing-of-join/197561/4 "2019-10-18T17:30:00Z")

</div>

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