|< < 36 > >|

MongoDB Data Model

JSON documents

Diaspora's experience with the MongoDB data model

Don't use references

Instead of duplicating user data, you can store references to users ...

Because we've moved some data out of the activity streams, we can no longer construct an activity stream from a single document. This is less efficient and more complex. Constructing an activity stream now requires us to 1) retrieve the stream document, and then 2) retrieve all the user documents to fill in names and avatars.

What's missing from MongoDB is a SQL-style join operation ... Because MongoDB doesn't have this ability, you end up manually doing that mashup in your application code, instead.

Once we started doing ugly MongoDB joins manually in the Diaspora code, we knew it was the first sign of trouble. It was a sign that our data was actually relational, that there was value to that structure, and that we were going against the basic concept of a document data store.

|< < 36 > >|