2

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

tjhack
  • 1,022
  • 3
  • 20
  • 43
  • 1
    possible duplicate of [A simple mongodb question: embed? or reference?](http://stackoverflow.com/questions/5373198/a-simple-mongodb-question-embed-or-reference) – Sean Reilly Aug 03 '12 at 12:01

1 Answers1

5

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.

Community
  • 1
  • 1
Adam Comerford
  • 21,336
  • 4
  • 65
  • 85