1

Imagine you have a collection of items (say A) around 50,000 but every item in it (say a) has a nested collection which can be huge say 20 million items (say B and an item in is refereed to as b). How do you recommend saving this in Mongodb?

A--a-B--b

Should I save it as it like the above And have you huge nested collections or should I flatten out the collections and actually represent the nested collection and at extra attributes on that defines what each item (b) belong to (A)?

1 Answer 1

4

You cannot have huge nested document, because there is a limit in document size in MongoDB (the link also gives good reasons why this limitation). So your documents inside collection nested inside a have to be into a separate collection and you should relate them somehow with a.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.