views:

184

answers:

1

In Mongo my understanding is that you can have databases and collections. I'm working on a social-type app that will have blogs and comments (among other things) and had previously be using MySQL and pretty heavy partitioning in an attempt to limit possible concurrency issues.

With MySQL I've stuffed all my user data into a _user database with several tables to further partition the data (blogs, pages, etc).

My immediate reaction with Mongo would be to create a 'users' database with one collection per user. In this way user 'zach' blog entries would go into the 'zach' collection with associated comments and such becoming sub-objects in the same collection. Basically like dynamically creating one table per user in MySQL, but apparently without the complexity and limitations that might impose.

Of course since I haven't really used Mongo before I'm having trouble gauging the (ahem..) quality of this idea and the potential problems it might cause down the road.

I'd like user data to be treated a lot like a users directory in a *nix environment where user created/non-shared (mostly) gets put into one place (currently with MySQL that would be the appname_users as mentioned above).

Most of the users data will be specific to the users page(s). Some of the user data which is queried across all site users (searchable user profiles) is currently kept in a separate database/table and I expect things like this could be put into a appname_system database and be broken up into collections and/or application specific databases (appname_profiles).

Anyway, since the available documentation on this is currently a little thin and my experience is extremely limited I thought I might find a little guidance from someone with a better working understanding of the system.

On the plus side I'd really already been attempting to treat MySQL as a schema-less document-store and doing this with Mongo seems much more intuitive/sane/rational so I'm really looking forward to getting started.

Thanks, Zach

+1  A: 

I have the same kind of application.

Some things to consider: you can cross query between collection bu not between databases. So It's probably better to have a database with all you data and then a collection for each Object.

Then each document can contain any kind and number of fields.

I tried to avoid embedding arrays b/c I had trouble query properly my object (it was working fine, but the architecture of my system was designed for this use)

And a database can be shared between several sever automatically so space is not an issue (if you have more than 1 server)

stunti
Thanks Stunti. Was hoping for a more collection related response but the database info is great help too. Since it doesn't look like I'll be seeing more responses I'll accept yours as the answer. Thanks a lot for sharing this!
zmg
Do you have an example for a query that crosses collections?
Thilo