what are the key points that one should think of while choosing betwee开发者_开发问答n embeds_many
and references_many
(or embeds_one
and references_one
) in Mongoid?
I'm currently preferring embeds_many
over references_many
, but that is resulting in too many nested embeds_many
'ies and I'm worried that it might add unnecessary overhead to the database.
The most important thing to be aware of is the 4 MB limit for each document in MongoDB - by using references instead of embedding documents, you can keep the size of your documents lower.
Other information about the differences can be found here.
I think that you should to use "entity-object" and "object-value" definitions from DDD. For entity use reference,but for "object-value" use embed document.
And check this question for more details about entity vs object-value.
精彩评论