# Another parent/child question with a many-to-1 relationship

**URL:** <https://discuss.elastic.co/t/another-parent-child-question-with-a-many-to-1-relationship/9666>\
**Category:** Elasticsearch\
**Created:** [November 12, 2012, 7:00am UTC](https://discuss.elastic.co/t/another-parent-child-question-with-a-many-to-1-relationship/9666 "2012-11-12T07:00:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![es\_learner](https://avatars.discourse-cdn.com/v4/letter/e/8dc957/32.png) [@es\_learner](https://discuss.elastic.co/u/es_learner)\
**Post date:** [November 12, 2012, 7:00am UTC](https://discuss.elastic.co/t/another-parent-child-question-with-a-many-to-1-relationship/9666/1 "2012-11-12T07:00:52Z")

</div>

I was using nested documents which grew to be unmanageable, so I started prototyping using parent/child.

Here's a problem I came across:

- a user can post comments to several topics, a topic being the parent and users the children
- in a nested doc model, topic A contains all its children independently of topic B. i.e. we dup a user profile for every topic he posted to
- in a parent/child model, a user posting to topic A and topic B can have a 'different' parent depending on the last topic he posted to.

How best to model this? Thanks.

---

<div class="post-metadata">

**Author:** ![es\_learner](https://avatars.discourse-cdn.com/v4/letter/e/8dc957/32.png) [@es\_learner](https://discuss.elastic.co/u/es_learner)\
**Post date:** [November 12, 2012, 9:48pm UTC](https://discuss.elastic.co/t/another-parent-child-question-with-a-many-to-1-relationship/9666/2 "2012-11-12T21:48:08Z")

</div>

One possible solution that I am thinking of is to use a composite id for the user's \_id.

e.g. child\_id = A.1 is really user id 1 in topic A, and  
child\_id = B.1 is user id 1 in topic B  
etc

I would not have unique children and the overhead would be essentially duplicate children.

Thoughts?

---

<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:** [July 6, 2017, 3:04am UTC](https://discuss.elastic.co/t/another-parent-child-question-with-a-many-to-1-relationship/9666/3 "2017-07-06T03:04:41Z")

</div>


