Re:3 reasons to use MongoDB
by rabidsnail on Thursday September 09, 2010 @01:10PM
(#1676042)
In real life you would have a users collection and an events collection, and the events field of users would be an array of event ids.
[ Parent
| on HN ]
My first response was "not necessarily," but I'm gonna ratchet it up a notch to a flat out "you're wrong."
Storing event_ids as an array in the events field defeats the whole purpose of organizing your data into rich documents.
In real life, you very well could build something where the events info was built straight into the user record.
Re:3 reasons to use MongoDB
by mathias_10gen on Thursday September 09, 2010 @03:06PM
(#1676481)
Actually it would probably be best to reverse the relation and put user_id's in the event objects. Then you can do queries like this:
db.events.find({hosted_by: MY_ID})
db.events.find({invited: MY_ID}) // invited is an array of usersseems like a relational database to me...only without the ability to join?