Reputation: 1032
I have created a mongodb database. I have a list of clients who are assigned to jobs.
I am trying to work out if storing client information just in the jobs document will be suffice. My only issue is that i need to have a central point where the client information will be stored and then within the jobs document i can have an object called client{_id: 'clientname'}
Would it be suffice to do it this way?
The only reason i ask is because if client details need to be updated such as address then this would be reflected immeditaly. If i stored the whole cleint object which contain name address etc then if they change their address for example then these changes would not be reflected.
cheers
Upvotes: 2
Views: 14743
Reputation: 21692
This is basically the classic embed versus reference question, and it has been asked many times. I like this thread: MongoDB relationships: embed or reference? as well as the relevant section of the documentation.
http://www.mongodb.org/display/DOCS/Schema+Design#SchemaDesign-EmbeddingandLinking
In the end it is a judgement call - the pros and cons are well known, you have to decide if your application fits better one way or the other, and then code appropriately around your decision.
Upvotes: 5