Search code examples
mongodbcollectionsstandardsdatabase

Deciding whether to create new collection or put data in existing collection using Mongo DB


I have data coming in from two sources, facebook and twitter. For each source I have multiple handles (pepsi, coke, sprite) and I want to determine the best way to organize my database.

Is it better practice to...

a. make two collections, one for twitter and one for facebook and have all all three handles in both collections?

b. make one collection and put all of that information in that single collection?

Thanks for your help. Mongodb is awesome.


Solution

  • Depends on many factors really, but generally speaking...

    If the data is somewhat similar and/or should be queried (aggregated) together then single collection is probably the best choice.

    If the data from twitter and fb should be processed in totally different ways then perhaps separated collections is a more appropriate solution.