Computer Science

What is MongoDB

MongoDB is a popular NoSQL database that stores data in flexible, JSON-like documents. It is designed to scale horizontally across multiple servers and can handle large amounts of unstructured data. MongoDB is commonly used in web applications and other modern software development projects.

Written by Perlego with AI-assistance

8 Key excerpts on "What is MongoDB"

  • Book cover image for: Big Data Analytics
    eBook - PDF

    Big Data Analytics

    A Practical Guide for Managers

    It is perhaps one of the best-known NoSQL databases in general use. One well-known user is Craigslist. MongoDB was designed more for analytics and complex data than it was for tables, ACID compliance, and all the other standards and support requirements that come with relational databases (being probably the most likely database variant in use today) 14 . The MongoDB website lists the following features, which we will discuss in detail 15 : • Document-oriented storage: JSON-style documents with dynamic schemas • Full index support: index on any attribute • Replication and high availability: mirror across LANs and WANs for scale • Auto-sharding: scale horizontally without compromising functionality • Querying: rich, document-based queries • Fast in-place updates: atomic modifiers for contention-free performance • Map/reduce: flexible aggregation and data processing • GridFS: store files of any size without complicating the stack • Professional support by MongoDB: support, training, and consult-ing available (they are a business) HBase and Other Big Data Databases • 125 MongoDB is considered to be a document-oriented database with strengths oriented around websites as well. Another feature, besides the lack of typical transactions, is the philosophy of keeping a copy of itself. These features make MongoDB useful for big data problems, since the database can be distributed. MongoDB uses a version of JSON called Binary-JSON (BSON) as a data description tool. BSON is an extension of JSON, which uses a length field to enhance the efficiency of scanning. The JSON approach provides less com-plexity than XML and more information than a comma-delimited file. The JSON world has its own argot, one example of which is the term “embedded document,” which occurs when basic information is made more complicated with the addition of more complex information—for example, an array. MongoDB is also a NoSQL database, which is a part of its nonrelational heritage.
  • Book cover image for: MongoDB Fundamentals
    eBook - ePub

    MongoDB Fundamentals

    A hands-on guide to using MongoDB and Atlas in the real world

    • Amit Phaltankar, Juned Ahsan, Michael Harrison, Liviu Nedov(Authors)
    • 2020(Publication Date)
    • Packt Publishing
      (Publisher)
    Founded in 2007 by Kevin P. Ryan, Dwight Merriman, and Eliot Horowitz in New York, the organization was initially called 10gen and was later renamed MongoDB—a word inspired by the term humongous. It provides both essential and extravagant features that are needed to store real-world big data. Its document-based design makes it easy to understand and use. It is built to be utilized for both experimental and real-world applications and is easier to set up and simpler to manage than most of the other NoSQL databases. Its intuitive syntax for queries and commands makes it easy to learn. The following list explores these features in detail: Flexible and Dynamic Schema : MongoDB allows a flexible schema for your database. A flexible schema allows variance in fields in different documents. In simple terms, each record in the database may or may not have the same number of attributes. It addresses the need for storing evolving data without making any changes to the schema itself. Rich Query Language : MongoDB supports intuitive and rich query language, which means simple yet powerful queries. It comes with a rich aggregation framework that allows you to group and filter data as required. It also has built-in support for general-purpose text search and specific purposes like geospatial searches. Multi-Document ACID Transactions : Atomicity, Consistency, Integrity, and Durability (ACID) are features that allow your data to be stored and updated to maintain its accuracy. Transactions are used to combine operations that are required to be executed together. MongoDB supports ACID in a single document and multi-document transactions. Atomicity means all or nothing, which means either all operations are a part of a transaction as it happens or none of them are
  • Book cover image for: Big Data Computing
    eBook - PDF

    Big Data Computing

    A Guide for Business and Technology Managers

    Document databases are probably the most popular type of NoSQL database. 11.4.1 CouchDB Cluster of Unreliable Commodity Hardware Data Base (CouchDB) is an open source, NoSQL, web-inclined database that uses JSON to store the data and relies on JavaScript as its query language. It uses HTTP for data access and merits with multimaster replication. CouchDB does not use tables at all for data storage or relationship management; rather it is a collection of independent documents, maintaining their self-contained schemas and data, which form the database. In CouchDB, multiversion concurrency control helps avoiding locks during write operation and document metadata holds the revision information and any offline data updates are merged and stale ones are deleted. CouchDB is equipped with a built-in administration web interface, called Futon. 11.4.2 MongoDB MongoDB (term extracted from the word humongous) is an open source, document- oriented NoSQL database. It enables master–slave replication: • Master performs reads and writes. • Slave copies the data received from master, performs the read operation, and backs up the data. Slaves do not participate in write operations but may select an alternate master in case the current master fails. Unlike the traditional relational databases, MongoDB uses a binary format of JSON-like documents and dynamic schemas. MongoDB enables flexible schemas and common fields of various documents in a collection can have disparate types of the data. The query system of MongoDB can return particular fields and query set compass search by fields, range queries, regular expression search, and so on, and may also include user- defined complex JavaScript functions. 269 Big Data NoSQL Databases The latest release of the data model is equipped with more advanced concepts such as sharding that address the scaling issues, and the replica sets that assist in automatic failover and recovery.
  • Book cover image for: Mastering MongoDB 4.x
    No longer available |Learn more

    Mastering MongoDB 4.x

    Expert techniques to run high-volume and fault-tolerant database solutions using MongoDB 4.x, 2nd Edition

    Putting the SQL to NoSQL differences aside, it is users from columnar-type databases that face the most challenges. With Cassandra and HBase being the most popular column-oriented database management systems, we will examine the differences and how a developer can migrate a system to MongoDB. The different features of MongoDB for NoSQL developers are as follows:
    • Flexibility : MongoDB's notion of documents that can contain sub-documents nested in complex hierarchies is really expressive and flexible. This is similar to the comparison between MongoDB and SQL, with the added benefit that MongoDB can more easily map to plain old objects from any programming language, allowing for easy deployment and maintenance.
    • Flexible query model : A user can selectively index some parts of each document; query based on attribute values, regular expressions, or ranges; and have as many properties per object as needed by the application layer. Primary and secondary indexes, as well as special types of indexes (such as sparse ones), can help greatly with query efficiency. Using a JavaScript shell with MapReduce makes it really easy for most developers (and many data analysts) to quickly take a look at data and get valuable insights.
    • Native aggregation : The aggregation framework provides an extract, transform, load (ETL ) pipeline for users to extract and transform data from MongoDB, and either load it in a new format or export it from MongoDB to other data sources. This can also help data analysts and scientists to get the slice of data they need in performing data wrangling along the way.
    • Schema-less model : This is a result of MongoDB's design philosophy to give applications the power and responsibility to interpret the different properties found in a collection's documents. In contrast to Cassandra's or HBase's schema-based approach, in MongoDB, a developer can store and process dynamically generated attributes.
    Passage contains an image

    MongoDB's key characteristics and use cases

    In this section, we will analyze MongoDB's characteristics as a database. Understanding the features that MongoDB provides can help developers and architects to evaluate the requirements at hand and how MongoDB can help to fulfill them. Also, we will go over some common use cases from the experience of MongoDB, Inc. that have delivered the best results for its users.
  • Book cover image for: Geographical Information Systems
    eBook - PDF

    Geographical Information Systems

    Trends and Technologies

    • Elaheh Pourabbas(Author)
    • 2014(Publication Date)
    • CRC Press
      (Publisher)
    Data in MongoDB has a schema-free model. Documents within a collection can be heterogeneous. MongoDB defines indexes on a collection level. Indexes can be created either on a single field or on multiple fields. All MongoDB indexes are implemented as a B-Tree data structure. Database replication with MongoDB helps to ensure redundancy and high availability (failover). Replication occurs through groups of servers known as replica sets. Replica sets are groups of MongoDB nodes; one set is designated as the primary and the others are designated the secondary members. The primary node is responsible for writing operations, while the secondary members replicate data from the primary one asynchronously. If the primary node fails, one of the secondary members is elected automatically as a new primary node (automatic failover). As such, MongoDB is strongly consistent. If clients change the setting to allow reading in secondary nodes, then MongoDB becomes eventually consistent where it is possible to read outdated results. MongoDB supports horizontal scaling via automatic sharding. Sharding partitions a collection and stores the different parts on different machines. Sharding automatically implements load balancing across machines in the cluster. Applications communicate with MongoDB through a client library or driver. There are MongoDB drivers available for the following programming languages: JavaScript, Python, Ruby, PHP, Perl, Java, Scala, C#, C, C++, Haskell, and Erlang. MongoDB Geospatial Indexes MongoDB provides the following geospatial index types to support geospatial queries: 2D and 2DSphere. Currently, MongoDB does not support 3D geospatial indexing. The 2D indexes are used for data stored as points on a two-dimensional plane (Euclidean plane). A 2D index should not be used for data stored as GeoJSON objects.
  • Book cover image for: SQL Pocket Primer
    No longer available |Learn more
    In simplified terms, think of a collection as a container-like entity that enables you to store documents. In addition, you can think of a document as a set of name/value pairs, where the values can be simple data types (e.g., numbers or strings) as well as arrays. Thus, MongoDB has a document-oriented data model instead of a table-oriented data model.
    MongoDB’s document-oriented model means that documents can be managed in their entirety instead of splitting them into components that are stored in different tables whose relationship must be defined, such as a one-to-many relationship that involves a foreign key.
    Instead, you create a collection and simply insert documents in that collection. MongoDB provides APIs for managing the documents in a given collection. the MongoDB performs a lazy creation of databases and collections, which means that databases and collections are created after you insert the first document.
    Document Format in MongoDB
    The documents in MongoDB are composed of field-and-value pairs and have the following structure:
    {   field1 → value1,   field2 → value2,   field3 → value3,   ...   fieldN → valueN }
    The value of a field can be any BSON datatype, including other documents, arrays, and arrays of documents. In practice, you’ll specify your documents using the JSON format.

    CREATE A MONGODB COLLECTION

    Unlike an RDBMS, MongoDB does not have a CREATE command. Instead, you need to invoke the use command to create a database, and then the INSERT
  • Book cover image for: Large Scale and Big Data
    eBook - PDF

    Large Scale and Big Data

    Processing and Management

    • Sherif Sakr, Mohamed Gaber, Sherif Sakr, Mohamed Gaber(Authors)
    • 2014(Publication Date)
    A collection is a group of documents. If a document is the MongoDB analog of a row in a relational database, then a collection can be thought of as the analog to a table. Collections are schema-free. This means that the documents within a single collection can have any number of different shapes. MongoDB groups collections into databases . A single instance of MongoDB can host several databases, each of which can be thought of as completely independent. It provides eventual consistency * http://memcached.org/. † http://hypertable.org/. ‡ http://couchdb.apache.org/. § http://www.mongodb.org/. ¶ http://www.10gen.com/. 299 An Overview of the NoSQL World guarantees in a way that a process could read an old version of a document even if another process has already performed an update operation on it. In addition, it pro-vides no transaction management so that if a process reads a document and writes a modified version back to the database, there is a possibility that another process may write a new version of the same document between the read and the write operation of the first process. MongoDB supports indexing the documents on multiple fields. In addition, it provides a very rich API interface that supports different batch operations and aggregate functions. Many other variant projects have followed the NoSQL movement and support different types of data stores such as key-value stores (e.g., Voldemort,* Dynomite † ), document stores (e.g., Riak ‡ ), and graph stores (e.g., Neo4j, § DEX ¶ ). 9.4 DATABASE-AS-A-SERVICE Multitenancy , a technique which is pioneered by salesforce.com , ** is an optimization mechanism for hosted services in which multiple customers are consolidated onto the same operational system and thus the economy of scale principles help to effectively drive down the cost of computing infrastructure.
  • Book cover image for: Big Data and Hadoo - 2nd Edition
    eBook - ePub

    Big Data and Hadoo - 2nd Edition

    Fundamentals, tools, and techniques for data-driven success (English Edition)

    Text search : MongoDB includes a powerful text search feature that enables you to perform full-text search queries on text fields. It supports language-specific stemming, stop words, and text index optimization for efficient searching.
  • Transactions : MongoDB supports multi-document transactions, allowing you to perform multiple operations as a single atomic unit of work. Transactions ensure data consistency and integrity in complex operations involving multiple documents.
  • GridFS : MongoDB provides a built-in file system specification called GridFS for storing and retrieving large files. Actual files are stored within MongoDB. It allows you to split files into smaller chunks and store them as documents in MongoDB, enabling efficient storage and retrieval of large files. GridFS does not function like a traditional file system on your operating system (it does not organize files in directories, for example), it serves as a protocol and a set of conventions for storing and retrieving large files in a database.
  • Following are few examples of the operations available in MongoDB. It offers a comprehensive set of features and capabilities for data storage, retrieval, manipulation, and analysis:
    • To establish foreign keys and to establish connections between documents, MongoDB provides references that connect different documents. It does not connect these automatically. It can be set manually by _id field.
      { $ref : < collectionname > , $id : < documentid >[ , $db : < dbname >] }
    • The selection query of MongoDB refers as the query object. Find the parameter used to collect queries.
      db . < collection >. find ( { title : " MongoDB " ) ;
      Other than this lot of operators are also allowed. < fieldname >: {$ < operator >: < value >} < fieldname >: {$ < operator >: < value > , $ < operator >: value } // AND - junction The preceding table use operator with value to allow for selection. For selecting modulo following table is required.
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.