Reputation: 611
If I'm trying to store key/value pairs of emails:phones, would it be better to have one document full of the emails:phones fields, or multiple documents, where the document.id would be the email and each document has one phone listed?
Example 1:
collectionA -> documentA -> "email1": (number) 1234567890,
"email2": (number) 1234567899,
...
Example 2:
collectionA -> documentA -> "email1": (number) 1234567890,
documentB -> "email1": (number) 1234567899
...
what if I have a dataset of 100? 1000? multiple thousands?
I think Example 2 would be better because Example 1 requires loading the whole document before accessing the desired key/value, right?
Edit: this is based on me knowing the email but not knowing the phone number.
Upvotes: 0
Views: 25
Reputation: 317352
It's only possible to determine which one is "better" if you examine specific use cases. Neither one is 100% is fully advantaged over the other.
Problems with #1:
Problems with #2:
You will have to pick which problems are less bad for your expected use cases.
Upvotes: 1