MongoDB is a document-oriented database. This means that it doesn’t use tables and rows to store its data, but instead collections of JSON-like documents. These documents support embedded fields, so related data can be stored within them.
MongoDB is also a schema-less database, so we don’t need to specify the number or type of columns before inserting our data.
Source: mongodb.com
MongoDB is a cross-platform, open-source, NoSQL database, used by many modern Node-based web applications to persist data.
Here’s an example of what a MongoDB document might look like:
{
_id: ObjectId(1dc123a1234k),
type: "Resources",
title: "Introduction to MongoDB",
author: "Davide C",
tags: [ "mongodb", "data science", "resources", "nosql" ],
categories: [
{
name: "javascript",
description: "the most popular nosql database for apps"
},
{
name: "databases",
description: "the most popular nosql database for apps"
},
],
content: "MongoDB is a cross-platform, open-source, NoSQL database..."
}
As you can see, the document has a number of fields (type
, title
etc.), which store values (“Resources”, “Introduction to MongoDB” etc.). These values can contain strings, numbers, arrays, arrays of sub-documents (for example, the categories
field), geo-coordinates and more.
The _id
field name is reserved for use as a primary key. Its value must be unique in the collection, it’s immutable, and it may be of any type other than an array.
As you might guess, a document in a NoSQL database corresponds to a row in an SQL database. A group of documents together is known as a collection, which is roughly synonymous with a table in a relational database.
#mongodb #programming #nosql-database #resources #data-science