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

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.