Java MongoDB Tutorial

MongoDB is a cross-platform, document-oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on the concept of collections and documents.

Before getting started with the Java MongoDB tutorial, let's first familiar with few MongoDB basic concepts like database, collection, and document.


The database is a physical container for collections. Each database gets its own set of files on the file system. A single MongoDB server typically has multiple databases.


A collection is a group of MongoDB documents. It is the equivalent of an RDBMS table. A collection exists within a single database. Collections do not enforce a schema. Documents within a collection can have different fields. Typically, all documents in a collection are of similar or related purposes.


A document is a set of key-value pairs. Documents have a dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structures, and common fields in a collection's documents may hold different types of data.

Mapping Relational Database to MongoDB - Summary

Collections in MongoDB are equivalent to the tables in RDBMS.
Documents in MongoDB are equivalent to the rows in RDBMS.
Fields in MongoDB are equivalent to the columns in RDBMS.
Fields (key and value pairs) are stored in a document, documents are stored in collection and collections are stored in a database.

MongoDB Tutorial for Beginners

Java MongoDB Tutorial Examples

MongoDB + Spring Boot Tutorials/Examples

MongoDB + Spring Boot + Angular Tutorials/Examples

MongoDB GitHub Repositories