Spring Boot & MongoDB

Farzin Pashaee
4 min readJun 13, 2022

MongoDB as the most popular NoSQL database is a source-available cross-platform document-oriented database program. It uses JSON-like documents with optional schemas and it is popular because of the ease with which data can be stored and retrieved.

MongoDB Introduction

MongoDB uses documents that contain a data structure composed of field and value pairs to store data so Documents are the basic unit of data in MongoDB. The documents are similar to JavaScript Object Notation, but use a variant called Binary JSON (BSON). BSON helps to have more data types and that is why MongoDB uses it. The overall terminology in MongoDB and RDBMS are similar and there are some small differences.

Database

The database is the container for collections. It has its own sets of files on the file system and a single MongoDB instance can have multiple databases.

Collection

MongoDB stores documents in collections. Collections are analogous to tables in relational databases. One of the benefits of collection compared to tables is that they do not enforce a schema and Documents within a collection can have different fields.

Document

Documents in MongoDB are equivalent to the rows in relational databases. Data is stored inside the documents in a set of key-value pairs and documents have a dynamic schema.

Join

Similar to join statement on RDBMS databases MongoDB has a similar concept that is used to related documents and joined them. Embedded documents help to mimic the join statement.

Getting Start

--

--

Farzin Pashaee

Software Engineer at Maybank, AI and ML enthusiastic