freeCodeCamp/guide/english/mongodb/index.md

2.5 KiB

title
MongoDB

MongoDB

MongoDB is an open-source non-relational database that uses a JSON-like structure to store data. It uses a document model to store and retrieve the data instead of the table model used by relational databases such as SQL or Oracle.

MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use. MongoDB in applications built with javascript is mainly used with Mongoose which is a package built on top of native mongo driver . It gives features like schema based design , virtuals , data validations etc. It makes the mongodb experience smooth and easy to use. You can learn more about mongoose here.

NoSQL Vs RDBMS

MongoDB Terms And Concepts SQL Terms and Concepts
Database Database
Collection Table
Document Row
Field Column
Index Index
Embedded Documents Table Joins

MongoDB Characteristics

  1. Next Generation Database
  2. No Joins
  3. Clustering
  4. Opensource
  5. Schema-Less
  6. No Relationships

Features of MongoDB

  1. Document Database
  2. High Performance
  3. Rich Query Language
  4. High Availability
  5. Horizontal Scalability
  6. Supports Indexing

Cons of MongoDB

  1. Schemaless design requires database manager to ensure certain constraints
  2. Indexing on multiple fields takes more memory
  3. Aggregation queries are at times non-intutive

Sample Document Structure

{
   "_id":ObjectId("52ffc33cd85242f436123532"),
   "name": "Rich Rick",
   "contact": "8826078979",
   "dob": "11-04-1997",
   "address": [
      {
         "building": "24 A, Indiana Apt",
         "pincode": 123456,
         "city": "Los Angeles",
         "state": "California"
      },
      {
         "building": "170 A, Acropolis Apt",
         "pincode": 456899,
         "city": "Chicago",
         "state": "Illinois"
      }
   ]
}

More Information

What is Mongo DB?

Wikipedia article on Document-oriented Databases

SQL vs NoSQL

Learn MongoDB from MongoDB

ACID vs BASE databases

Getting Started with MongoDB