I am using MongoDB to store products, user accounts and stuff on my server and so far it's going nice.
But now I'm stuck deciding how do I "split" things apart, like:
I have a database where products are stored, but now I want to log every change made (who made it, when, etc).
Should I put that log (array) in the same (product) document, or should I separate the log in a separate collection?
products:
{
_id: 1234
product_name: "Some product"
}
product_changes:
{
_id: ...
ref_id: 1234
changes: ["...","..."]
}
or
products:
{
_id: 1234
product_name: "Some product"
changes: ["...","..."]
}
I'm afraid that if I attach too much Objects in one document, that the performance will suffer, and if I separate everything, things begin to "fragment".
Of course, in the example, "changes" is just a tiny array, but in real usage it may be a array with a lot of objects each with time, user_id and changes made. And summing all this up, might turn this single document big.
Any help on this is greatly appreciated.