1

In learning the MongoDB platform, I'm at data models and see you can use embedding or references. My question is simple. Is there ever a need to use both? For example, I can see storing user contact data in an embedded document but perhaps storing transactions of the user (which could grow exponentially - think of your average high-rated eBay seller) in a reference model.

Was curious if its generally accepted that some applications will contain the blend. Wasn't very clear in the docs.

Thank you!

Community
  • 1
  • 1
webkenny
  • 221
  • 1
  • 7

1 Answers1

1

Thing is, mongodb doesn't have "joins" (you have to do it manually on the client side). Considering this you need to be careful on how you use referencing (as you'll have to do multiple queries to retrieve the information). Like you said, If you have something that can grow exponentially referencing might be a good option.

So, to answer your question directly - yes, blending is the way. You have to analyze each of your cases and choose based on your needs.

I'll leave a link to another question that discusses the embedding vs referencing topic.

Community
  • 1
  • 1
joao
  • 4,067
  • 3
  • 33
  • 37