liveBook · Manning

MongoDB document

As explained in Java Persistence with Spring Data and Hibernate epub

A MongoDB document is a BSON record consisting of field-value pairs that represents a stored data object.

A MongoDB document is a BSON record of field-value pairs representing a stored data object. Documents reside in collections, which reside in databases. Documents in one collection may use different fields or types, enabling dynamic schemas. section 17.1

Table 17.1 Compared terminology: RDBMS vs. MongoDB (view table figure)

Relational databases

MongoDB

Database

Database

Table

Collection

Row

Document

Column

Field

Use the terminology comparison to translate between MongoDB and relational database concepts: collection/table, document/row, and field/column. section 17.1

A user document

A stored user document can contain an identifier, username, personal names, registration date, email, numeric level, active flag, and mapped Java class name. MongoDB Compass can filter it with {"username":"john"}. section 17.1

Design and persistence implications include:

  • Treat fields as document properties rather than assuming every document shares one fixed relational schema. section 17.1
  • Reference another document with a DBRef containing the target collection and identifier; embedding documents is not supported by Spring Data MongoDB. section 17.5
  • Persist or delete referenced documents explicitly because save and delete operations do not cascade between documents. section 17.5

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Defines fields, dynamic schemas, references, and non-cascading lifecycle behavior without detailing BSON internals.
Examples
Uses user and address documents, MongoDB Compass filters, and DBRef-backed user-to-address storage.
What you can do after
Operate/configure MongoDB Compass to inspect collections and filter documents by field values.
How it connects
Connects databases, collections, fields, relational database terminology, DBRefs, and Spring Data MongoDB.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.