2015년 1월 1일 목요일

Collections vs. Databases

I have a need to store data for multiple companies that could have tens-of-thousands of documents each, I would like to know how best to segment the companies' data (for security and efficiency).

I'm wondering which of the following configurations would be best:

  • Using collections: db.[company].collection.save({ "foo":"bar" })
OR
  • Using Databases: [company].collection.save({ "foo":"bar" })

...of course also giving weight to being manageable for replica sets.

If the second case is preferable, how would I create the databases programmatically at runtime as companies accumulate?

Thanks in advance for any guidance!




You'd have to give some more details about how many companies, how
many collections/documents pertaining to each, how the querying/access
would be done (like do you ever need to query across multiple
companies documents) to make a definitive recommendation.

But the answer to:
> create databases programmatically at runtime

you don't - you just start inserting into a new database/collection
and it will be created if it doesn't exist.


댓글 없음:

댓글 쓰기