Lab: Tree Patterns, understanding the answer

The correct answer of the lab is only the Parent References pattern. I thought that It was the Parent References and Array of Ancestors.

Array of Ancestor could be applied to the problem of the lab but It’s explained that:
"Array of Ancestors is a pattern that allows us to perform all of the requested queries in an efficient way, however the update operation would not be possible with a single update operation.

One single update operation to change the reporting structure of an employee

To exemplify this scenario let’s promote “Stuart Spencer” and have him report to “Jalpa Maganin”

The reports_to field in “Stuart Spencer” document could be performed with a single update.

However, we would also need to run several updates, to reflect this new structure, on all of “Stuart Spencer” subsequent reports, which requires at least one other update."

Well, what wasn’t clear to me is what does happen when the same scenario used to explain the incorrect application of the Array of Ancestors is applied to the Parent References?

When does Stuart Spencer is moved to report to Jalpa Maganin, Jon Yullin stills to report to Stuart Spencer?

Or better, When does a manager is moved to another position in the tree, your reports still to report to him?

Hey @Halex_Viotto_Gomes,

We would need to run several updates, on all of Stuart Spencer’s reports, since in the case of Array of Ancestors, we keep a list of all ancestors of that entity. So for all of Stuart’s reports, we need to update reports_to to include name of all ancestors. But in the case of Parent Reference, all of Stuart’s reports will only contain the name of Stuart, which they already contain and only Stuart’s reports_to field will change, hence the single update.

Let us know if there’s still any confusion in this. I would advise you to re-read the documentation as well.

Feel free to reach out for anything else as well.

Regards,
Satyam

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