I am using mongodb in my rails app with odm mongoid
My questions are easy:
a) when associations between objects should be embedded or referenced?
b) how does this affect the application performance?
Thank you very much!
I am using mongodb in my rails app with odm mongoid
My questions are easy:
a) when associations between objects should be embedded or referenced?
b) how does this affect the application performance?
Thank you very much!
Referenced relationships require multiple db lookups; embedded relationships don't. But referenced relationships are easier to work with (especially if you are just starting out with your app and/or with mongo). I would recommend that you stay with referenced relationships until you have a better sense of the shape of your app and your data needs; at that point you can denormalize your data by switching some of those referenced relationships to embedded.
I would also recommend https://github.com/dzello/mongoid_alize to help with denormalization.