MongoDB Terminology

In this tutorial you will learn about the MongoDB Terminology and its application with practical example.

MongoDB Terminology (Common Terms)

Database :- In MongoDB, Database is a physical container that holds the set of collections. A database may contain zero or more collections. A MongoDB server instance can host multiple databases. There is no limit on the number of databases that can be hosted on single instance, but it is limited to the virtual memory address space that can be allocated by the underlying operating system.

Collection :- Collection is a set of MongoDB documents. It is similar to the “Tables” in relational database systems. Collections are schema less, thus documents within same collection can have different fields. Typically, a collection holds the documents of similar or related purpose.

Document :- In MongoDB, Document is the basic unit of storing data in MongoDB database. Documents are analogous to the ROW in traditional relational database systems. It is an ordered set of key-value pairs, means for every key there exists an associated value. Document are more oftenly referred to as “Objects”. Every document/object in a collection is represented in a JSON-like(key-value pairs) format. Data is stored and queried in BSON, it is a binary representation of JSON-like data.

Example:-

Field :- In MongoDB, fields are analogous to columns in relational databases. A document in a collection can have zero or more fields. A field and its associated value are stored in key-value pairs.

_id :- It is a mandatory field in every MongoDB document. It is used to represents a unique document in a collection. It works as the document’s primary key. If you create a new document without an _id field, MongoDB will automatically create the field.

MongoDB v/s RDBMS Terminology/Concepts

If you’re not familiar with MongoDB, here is a quick translation table that presents the various SQL terminology and concepts and the corresponding MongoDB terminology and concepts.

SQL Terms/Concepts MongoDB Terms/Concepts
database database
table collection
row document or BSON document
column field
index index
table joins embedded documents and linking
primary key

Specify any unique column or column combination as primary
key.

primary key

In MongoDB, the primary key is automatically set to the
_id field.

In this tutorial we have learn about the MongoDB Terminology and its application with practical example. I hope you will like this tutorial.