MongoDB: Difference between revisions
→Features: Removed misplaced </ref> tag under the "Indexing" header |
|||
Line 49: | Line 49: | ||
:MongoDB supports search by field, range queries, regular expression searches. Queries can return specific fields of documents and also include <u>user-defined JavaScript functions</u>. |
:MongoDB supports search by field, range queries, regular expression searches. Queries can return specific fields of documents and also include <u>user-defined JavaScript functions</u>. |
||
;Indexing |
;Indexing |
||
:Any field in a MongoDB document can be indexed (indexes in MongoDB are conceptually similar to those in RDBMSes). Secondary indexes are also available |
:Any field in a MongoDB document can be indexed (indexes in MongoDB are conceptually similar to those in RDBMSes). Secondary indexes are also available. |
||
;Aggregation |
;Aggregation |
||
:[[MapReduce]] can be used for batch processing of data and aggregation operations. The aggregation framework enables users to obtain the kind of results SQL group-by is used for |
:[[MapReduce]] can be used for batch processing of data and aggregation operations. The aggregation framework enables users to obtain the kind of results SQL group-by is used for |
Revision as of 14:11, 7 March 2012
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
No issues specified. Please specify issues, or remove this template. |
This article needs attention from an expert in Computing. Please add a reason or a talk parameter to this template to explain the issue with the article.(January 2012) |
logo | |
Developer(s) | 10gen |
---|---|
Initial release | 2009 |
Stable release | 2.0.3
/ February 27, 2012 |
Repository | |
Written in | C++ |
Operating system | Cross-platform |
Available in | English |
Type | Document-oriented database |
License | GNU AGPL v3.0 (drivers: Apache license) |
Website | www |
MongoDB (from "humongous") is an open source document-oriented NoSQL database system.
MongoDB makes part of the "new" NoSQL family of database systems. Instead of storing data in tables as is made in a "classical" relational database, MongoDB store structure data as JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making easier and faster the integration of data in certain type of applications.
Development of MongoDB began in October 2007 by 10gen. It is now a mature and feature rich database ready for production use. It's used, by example, by MTV Networks[1], Craigslist[2] or Foursquare[3].
The goal of the MongoDB project is to bridge the gap between key-value stores (which are highly scalable) and relational databases (which have rich functionality).[4][5]
Binaries are available for Windows, Linux, OS X, and Solaris.[6]
History
Development of MongoDB began at 10gen in 2007, when the company was building a Platform as a Service similar to Google App Engine.[7]. In 2009 MongoDB was open sourced as a stand-alone product.[8], with an AGPL license.
In March 2011, from version 1.4, MongoDB has been considered production ready[9].
The last stable version (in March 2012) is 2.0.3, released in February 2012.
Features
A summary of main features could be the following
- Ad hoc queries
- MongoDB supports search by field, range queries, regular expression searches. Queries can return specific fields of documents and also include user-defined JavaScript functions.
- Indexing
- Any field in a MongoDB document can be indexed (indexes in MongoDB are conceptually similar to those in RDBMSes). Secondary indexes are also available.
- Aggregation
- MapReduce can be used for batch processing of data and aggregation operations. The aggregation framework enables users to obtain the kind of results SQL group-by is used for
- File storage
- The software implements a protocol called GridFS[10] that is used to store and retrieve files from the database (used, by example, in plugins for NGINX[11] and lighttpd.[12])
- Server-side JavaScript execution
- JavaScript can be used in queries, aggregation functions (such as MapReduce), are sent directly to the database to be executed.
- Capped collections
- MongoDB supports fixed-size collections called capped collections. This type of collection maintains insertion order and, once the specified size has been reached, behaves like a circular queue.
For further information on the points listed look up the MongoDB Developer Manual
Data manipulation
Collections and Documents
MongoDB store structure data as JSON-like documents with dynamic schemas (called BSON), with no predefined schema.
The element of data is called documents, stored in collections. One collection may have any number of documents.
Compared to relational databases we could say collections are as tables, and documents are as records. But there is one big difference: every record in a table have the same number of fields, while documents in a collection could have completely different fields.
One table SQL could be represented as
Last Name | First Name | Age |
---|---|---|
DUMONT | Jean | 43 |
PELLERIN | Franck | 29 |
MATTHIEU | Nicolas | 51 |
- Every record in a SQL table a the same fields
However a MongoDB collection could be described as
{
"_id": ObjectId("4efa8d2b7d284dad101e4bc9"),
"Last Name": "DUMON",
"First Name": "Jean",
"Age": 43
},
{
"_id": ObjectId("4efa8d2b7d284dad101e4bc7"),
"Last Name": "PELLERIN",
"First Name": "Franck",
"Age": 29,
"Address": "1 chemin des Loges",
"City": "VERSAILLES"
}
- Documents in a MongoDB collection could have different fields (note: "_id" field is obligatory, automatically created by MongoDB, it's an unique index which identify the document
In a document, new fields could be added, existing ones suppressed, modified or renamed at any moment. There is no predefined schema. A document structure is really simple and composed of key-value pairs like associative arrays in programming languages (following the JSON format). The key is the field name, the value is its content. Both are separated by ":", as in the example shown.
As value we could use numbers, strings and also binary data like images or another key-value pairs as in the following example:
{
"_id": ObjectId("4efa8d2b7d284dad101e4bc7"),
"Last Name": "PELLERIN",
"First Name ": "Franck",
"Age": 29,
"Address":
{
"Street" : "1 chemin des Loges",
"City": "VERSAILLES"
}
}
Here we can see that the field "Address" contains another document with two fields "Street" and "City".
Deployment
MongoDB can be built and installed from source, but it is more commonly installed from a binary package. Many Linux package management systems now include a MongoDB package, including CentOS and Fedora,[13] Debian and Ubuntu,[14] Gentoo[15] and Arch Linux.[16] Also OS X Homebrew package manager includes MongoDB.[17] It can also be acquired through the official website.[18]
MongoDB uses memory-mapped files, limiting data size to 2GB on 32-bit machines (64-bit systems have a much larger data size).[19] The MongoDB server can only be used on little-endian systems, although most of the drivers work on both little-endian and big-endian systems.
Language support
MongoDB has official drivers for:
- C[20]
- C++[21]
- C#[22]
- Erlang[23]
- Haskell[24]
- Java[25]
- JavaScript[26]
- Lisp[27]
- Perl[28]
- PHP[29]
- Python[30]
- Ruby[31]
- Scala[32]
There are also a large number of unofficial drivers, for C# and .NET,[22] ColdFusion,[33] Delphi,[34] Erlang,[35][36] Factor,[37] Fantom,[38] Go,[39] JVM languages (Clojure, Groovy,[40] Scala, etc.),[41] Lua,[42] node.js,[43] HTTP REST,[44] Ruby,[45] Racket,[46] and Smalltalk.[47]
Replication
MongoDB supports master-slave replication. A master can perform reads and writes. A slave copies data from the master and can only be used for reads or backup (not writes).
MongoDB allows developers to guarantee that an operation has been replicated to at least N servers on a per-operation basis.
Master-slave
As operations are performed on the master, the slave will replicate any changes to the data.
Replica sets
Replica sets are similar to master-slave, but they incorporate the ability for the slaves to elect a new master if the current one goes down.
Sharding
MongoDB scales horizontally using a system called sharding[48] which is very similar to the BigTable and PNUTS scaling model. The developer chooses a shard key, which determines how the data in a collection will be distributed. The data is split into ranges (based on the shard key) and distributed across multiple shards. (A shard is a master with one or more slaves.)
Management and graphical frontends
Official tools
The database shell lets developers view, insert, remove, and update data in their databases, as well as get replication information, setting up sharding, shut down servers, execute JavaScript, and more. mongo is built on SpiderMonkey, so it is a full JavaScript shell as well as being able to connect to MongoDB servers.[49]
Administrative information can also be accessed through the web interface a simple webpage that serves information about the current server status. By default, this interface is 1000 ports above the database port (http://localhost:28017) and it can be turned off with the --norest option.
mongostat is a command-line tool that displays a simple list of stats about the last second: how many inserts, updates, removes, queries, and commands were performed, as well as what percentage of the time the database was locked and how much memory it is using.
mongosniff sniffs network traffic going to and from MongoDB.
Monitoring
There are monitoring plugins available for MongoDB:
- munin[50]
- ganglia[51]
- scout[52]
- cacti[53]
- MongoDB Monitoring Service (MMS) is free monitoring and alerting solution for MongoDB deployments
GUIs
Several GUIs have been created by MongoDB's developer community to help visualize their data. Some popular ones are:
- phpMoAdmin[54] - a full-featured PHP GUI that runs entirely from a single 95kb self-configuring file, built over the Vork Enterprise Framework
- Fang of Mongo[55] – a web-based UI built with Django and jQuery.
- Futon4Mongo[56] – a clone of the CouchDB Futon web interface for MongoDB.
- JMongoBrowser[57] – a desktop application for all platforms.
- Mongo3[58] – a Ruby-based interface.
- MongoHub[59] – a native Mac OS X application for managing MongoDB.
- Opricot[60] – a browser-based MongoDB shell written in PHP.
- Database Master - MongoDB Management Tool - Supports also RDBMS like: Oracle, SQLServer, MySQL
- BI Studio - Business Intelligence Software for RDBMS and MongoDB.
Licensing and support
MongoDB is available for free under the GNU Affero General Public License. The language drivers are available under an Apache License.[61] In addition, 10gen offers commercial licenses for MongoDB.[62]
Epoch Issues
Objects in MongoDB are assigned an ObjectID, which incorporates a 32 bit representation of time in seconds since epoch (which in computers is typically seconds since the start of 1970), and another 64 bits containing a 24 bit machine id, 16 bit process id, and a 24 bit counter. As with all fixed size representations of time, this is susceptible to rollover, specifically the Year 2038 problem. Applications built upon mongo that make use of the embedded time representation contained within the ObjectID would misinterpret dates even though MongoDB itself would continue to function.
Prominent users
- MTV Networks[1]
- craigslist[2]
- Disney Interactive Media Group[63]
- Wordnik[64]
- diaspora[65]
- Shutterfly[66]
- foursquare[3]
- bit.ly[67]
- The New York Times[68]
- SourceForge[69]
- Business Insider[70]
- Etsy[71]
- CERN LHC[72]
- Thumbtack[73]
- AppScale[74]
- Uber[75]
- The Guardian[76]
See also
References
- ^ a b "MongoDB Powering MTV's Web Properties". 2011-05-10. Retrieved 2011-07-06.
- ^ a b "MongoDB live at craigslist". 2011-05-16. Retrieved 2011-07-06.
- ^ a b "MongoDB at foursquare - Presentation at MongoNYC". 2010-05-21. Retrieved 2010-06-28.
- ^ http://www.10gen.com/what-is-mongodb
- ^ http://www.mongodb.org/display/DOCS/Philosophy
- ^ http://www.mongodb.org/downloads
- ^ MongoDB daddy: My baby beats Google BigTable
- ^ The MongoDB NoSQL Database Blog, The AGPL
- ^ The MongoDB NoSQL Database Blog, MongoDB 1.4 Ready for Production
- ^ GridFS
- ^ NGINX
- ^ lighttpd
- ^ CentOS and Fedora
- ^ Debian and Ubuntu,
- ^ Gentoo
- ^ Arch Linux
- ^ [1]
- ^ official website
- ^ [2]
- ^ C driver
- ^ C++ driver
- ^ a b C# driver Cite error: The named reference "csharp" was defined multiple times with different content (see the help page).
- ^ Erlang driver
- ^ Haskell driver
- ^ Java driver
- ^ JavaScript driver
- ^ [3]
- ^ Perl driver
- ^ PHP driver
- ^ Python driver
- ^ Ruby driver
- ^ Casbah, the officially supported Scala Driver for MongoDB
- ^ ColdFusion driver
- ^ Delphi
- ^ Emongo Erlang driver
- ^ Erlmongo Erlang driver
- ^ Factor driver
- ^ Fantom driver
- ^ gomongo Go driver
- ^ GMongo
- ^ JVM language center
- ^ LuaMongo
- ^ node.js driver
- ^ REST interface
- ^ rmongo
- ^ [4]
- ^ Smalltalk driver
- ^ sharding
- ^ http://www.mongodb.org/display/DOCS/mongo+-+The+Interactive+Shell
- ^ Munin plugin
- ^ Ganglia plugin
- ^ Scout slow-query plugin
- ^ Cacti plugin
- ^ phpMoAdmin
- ^ Fang of Mongo
- ^ Futon4Mongo
- ^ JMongoBrowser
- ^ Mongo3
- ^ MongoHub
- ^ Opricot
- ^ The AGPL - MongoDB Blog: May 5, 2009
- ^ http://www.10gen.com/commercial-licenses
- ^ "Disney Central Services Storage: Leveraging Knowledge and skillsets". 2011-05-24. Retrieved 2011-07-06.
- ^ "12 Months with MongoDB". 2010-10-25. Retrieved 2011-05-24.
- ^ "MongoDB - diasporatest.com". 2010-12-23. Retrieved 2010-12-23.
- ^ "Implementing MongoDB at Shutterfly - Presentation at MongoSF". 2010-04-30. Retrieved 2010-06-28.
- ^ "bit.ly user history, auto-sharded - Presentation at MongoNYC". 2010-05-21. Retrieved 2010-06-28.
- ^ Maher, Jacqueline (2010-05-25). "Building a Better Submission Form". NYTimes Open Blog. Retrieved 2010-06-28.
- ^ "How Python, TurboGears, and MongoDB are Transforming SourceForge.net". PyCon 2010. 2010-02-20. Retrieved 2010-06-28.
- ^ "How This Web Site Uses MongoDB". Business Insider. 2010-11-06. Retrieved 2010-06-28.
- ^ "MongoDB at Etsy". Code as Craft: Etsy Developer Blog. 2010-05-19. Retrieved 2010-06-28.
- ^ "Holy Large Hadron Collider, Batman!". The MongoDB NoSQL Database Blog. 2010-06-03. Retrieved 2010-08-03.
- ^ "Building Our Own Tracking Engine With MongoDB". Thumbtack Blog. 2011-05-03. Retrieved 2011-05-15.
- ^ http://appscale.cs.ucsb.edu/datastores.html#mongodb
- ^ "Node.js Meetup: Distributed Web Architectures – Curtis Chambers, Uber | JoyentCloud:". Retrieved 12 August 2011.
- ^ www.infoq.com/presentations/Why-I-Chose-MongoDB-for-Guardian
Bibliography
- Banker, Kyle (March 28, 2011), MongoDB in Action (1st ed.), Manning, p. 375, ISBN 9781935182870
- Chodorow, Kristina; Dirolf, Michael (September 23, 2010), MongoDB: The Definitive Guide (1st ed.), O'Reilly Media, p. 216, ISBN 9781449381561
- Pirtle, Mitch (March 3, 2011), MongoDB for Web Development (1st ed.), Addison-Wesley Professional, p. 360, ISBN 9780321705334
- Hawkins, Tim; Plugge, Eelco; Membrey, Peter (September 26, 2010), The Definitive Guide to MongoDB: The NoSQL Database for Cloud and Desktop Computing (1st ed.), Apress, p. 350, ISBN 9781430230519
External links
- Official MongoDB Project Website
- MongoDB with ZanPHP Spanish Documentation
- mongoDB User Group on LinkedIn
- MongoDB news and articles on myNoSQL
- Eric Lai. (2009, July 1). No to SQL? Anti-database movement gains steam
- Videos about MongoDB on MrBool.com
- MongoDB articles on NoSQLDatabases.com
- June 2009 San Francisco NOSQL Meetup Page
- Designing for the Cloud at MIT Technology Review
- EuroPython Conference Presentation
- Non-relational data persistence in Java using MongoDB - Software Engineer at MongoDB on YouTube
- Interview with Mike Dirolf on The Changelog about MongoDB background and design decisions
- MongoMvc - A MongoDB Demo App with ASP.NET MVC
- FAQs about MongoDB
- Is MongoDB a good alternative to RDBMs databases?