Reflections on MongoDB
collectiveidea.com
collectiveidea.com
every time i read mongodb blog posts i read things like this in the comments and i decide to pass...
If it is with MongoDB, I’m hopeful that it is a result of MongoDBs immaturity, and over time it will become more stable.
Always.
I am a big fan of mongodb but this is bad advice. The answer should be 'when I need a document-based data store'. You determine what type of database you need (RDBMS, KV, Doc, Graph, Column-based etc.) based on the type of data you are storing and retrieving. You don't want to use mongo for an accounting database etc. That said, mongo is the most mature, stable and feature rich of the open source doc based db's.
NO, NO, NO. If you do that, then you’re definitely doing it wrong! Again! http://nosql.mypopescu.com/post/703837964/when-should-i-use-...
"No, seriously!?
OK, I think MongoDB makes sense with most web applications...."
For example, let's say you have a blog that's using a key-value store, and posts can have many tags. Does each post document have the tags in the record itself, or does the post document have the ids for the tag records, which the system would retrieve in a subsequent query? Or am I missing it completely? Links to any helpful articles on transitioning from a relational database to a document store would be awesome.
It all depends on your use case.
Do the data stores do de-duplication internally to make this less expensive storage-wise?
http://blog.basho.com/2010/03/19/schema-design-in-riak---int...
http://blog.basho.com/2010/03/25/schema-design-in-riak---rel...
Users
{
_id:string //doubles for user's name
password: {
hash:string
salt:string
}
website:string
bio:string
following:array of {
username:string
articles:boolean
comments:boolean
}
}
Articles {
_id:ObjectID //auto id
title:string
contents:string
owner:string //references Users
tags:array of strings //no reference, tags are either unfiltered or selected from a global tag list.
}
Comments {
_id:ObjectID //auto id
contents:string
owner:string //references Users
root:ObjectID //references Articles instead of Comments
parents:array of ObjectIDs //using materialized path for threading of comments
}
Config {
_id:string
value:? //untyped can store anything in json format
}
Note: The references are defined entirely in software, the database is not aware of them.- Adding to a shopping basket is adding a row to a table which is atomic (same for deletions)
- topping up a online credit is "UPDATE credit_balance SET credit=new_value WHERE credit=expected_old_value AND user_id=this_user", which is atomic and then check the number of affected rows is 1.
Document-based DBs are not RDBMSs, and consequently you can't (or rather, shouldn't) just apply your traditional database design methodology to it.