Skip to Content
MongoDB: The Definitive Guide, 3rd Edition
book

MongoDB: The Definitive Guide, 3rd Edition

by Shannon Bradshaw, Eoin Brazil, Kristina Chodorow
December 2019
Intermediate to advanced
511 pages
12h 50m
English
O'Reilly Media, Inc.
Book available
Content preview from MongoDB: The Definitive Guide, 3rd Edition

Chapter 2. Getting Started

MongoDB is powerful but easy to get started with. In this chapter we’ll introduce some of the basic concepts of MongoDB:

  • A document is the basic unit of data for MongoDB and is roughly equivalent to a row in a relational database management system (but much more expressive).

  • Similarly, a collection can be thought of as a table with a dynamic schema.

  • A single instance of MongoDB can host multiple independent databases, each of which contains its own collections.

  • Every document has a special key, "_id", that is unique within a collection.

  • MongoDB is distributed with a simple but powerful tool called the mongo shell. The mongo shell provides built-in support for administering MongoDB instances and manipulating data using the MongoDB query language. It is also a fully functional JavaScript interpreter that enables users to create and load their own scripts for a variety of purposes.

Documents

At the heart of MongoDB is the document: an ordered set of keys with associated values. The representation of a document varies by programming language, but most languages have a data structure that is a natural fit, such as a map, hash, or dictionary. In JavaScript, for example, documents are represented as objects:

{"greeting" : "Hello, world!"}

This simple document contains a single key, "greeting", with a value of "Hello, world!". Most documents will be more complex than this simple one and often will contain multiple key/value pairs:

{"greeting" : "Hello, world!", "views" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

MongoDB - The Complete Developer's Guide

MongoDB - The Complete Developer's Guide

Maximilian Schwarzmüller
The Complete Node.js Developer Course (3rd Edition)

The Complete Node.js Developer Course (3rd Edition)

Andrew Mead, Codestars By Rob Percival

Publisher Resources

ISBN: 9781491954454Errata Page