Deeply nested documents


I’m trying to start to “translate” a MySQL database to the MongoDB structure, little by little. But I got the following doubt. Say I have three tables “Projects” “Tasks” and “Works”, the three of them with several rows and all totally related (there’s no work without a task and there’s no task without a project)

Although every Documents, “projects” for instance, has its own nested fields, they don’t go deeper than three levels. But if I nest the “Tasks” documents, and the “Works” documents, the nested level can reach the 5th level.

I wonder what is more efficient, if nest the three documents to that level, or keep them separate and deal with the “join” when it comes to relate works with tasks and projects. Certainly it must be a trade off, so the question is; at what level of deepness is convenient to nest documents inside others?

@Rodrigo_Alonso_30601 this question requires a holistic view of a myriad of things. Suggest you take the M320 Data Modelling course that discusses some of the design considerations and patterns that will suit your use case.

1 Like