Reputation: 17087
MongoDb is known as a document database as opposed to a key value data store. But the mongodb docs
examples:
{ "item": "pencil", "qty": 500, "type": "no.2" }
This looks exactly like a collection of key value pairs. So is there a fundamental difference between document database and key value pair database
Upvotes: 6
Views: 3662
Reputation: 65
In a recent interview with MongoDB architects, their opening statement to me was "MongoDB is basically a key:value data store." So, yes, it is a collection of keys and their values. It is more but it is that.
Upvotes: 0
Reputation: 130
A more easy way to distinguish is to look at Memcached and MongoDB. Memcached is simply a key-value store, but MongoDB includes a much more rich data structure, in which you can store Arrays, Dict and query them quite easily.
Upvotes: 0
Reputation: 2446
The definitions are not exclusive.
A "Key-Value database" defines that the "Value" part of the data to retrieve can be accessed directly by querying the database for its "Key", as opposed to define database schemas and querying the database using SQL syntax. The "Value" could be anything, a simple string, a programming language object, an HTML page...
Document database says more about the "Value" part of the Key-Value pair: the data retrieved is encoded in some standard, portable format, as JSON or XML. This gives the database some structure, but nowhere near as rigid as a traditional database where every row has to conform to the defined schema.
So, to answer your question, MongoDB is a database that uses a "Key-Value" mechanism to retrieve data, with its "Value" being a Document (as loosely defined by the definition of Document based database).
Take into account that the NoSQL "definitions" are a bit overlapping and quite loose.
Upvotes: 6