Tag: Mongodb
Creating Data Relations in MongoDB
2021-06-03Unlike relational databases, there are no native methods for relations in MongoDB. However, we can try to create relations by referencing the _id between documents.
We will continue to use the sample database, sample_supplies, for this demo. In the …
Schema Validation in MongoDB
2021-06-02Schema validation
While MongoDB does not enforce data type validation by default, it can be enabled by specifying validation rules when creating a collection.
// Use database: sample_supplies
> use sample_supplies
switched to db …
MongoDB Bulk Write
2021-06-01bulkWrite() method
db.collection.bulkWrite()
method can perform these operations:
- insertOne
- updateOne
- updateMany
- replaceOne
- deleteOne
- deleteMany
It has the following syntax:
db.collection(
[
{
<operation1>: { …
MongoDB Aggregation Pipeline
2021-05-31Aggregation pipeline stages
Aggregation pipeline is an array of aggregation methods that process data stage-by-stage until a result is returned at the end of the pipeline.
Aggregation pipeline stages for a collection is executed by the …
A Practice Scenario for MongoDB
2021-05-30Managing inventory for an office supply store
Imagine running an office supply company. We need to keep track of customer information, sales data, and store location.
Sales data query
We may ask these questions related to sales …
MongoDB Basic CRUD Operations
2021-05-29How records are stored
- Each record is called a Document, which is BSON formatted.
- Documents are grouped into a Collection.
- Collections are grouped into a Database.
List all DB
> show dbs
admin 0.000GB
config 0.000GB
local …
MongoDB Import Data
2021-05-28Sample data source
A variety of sample data is provided by the developers of MongoDB. They can be found here:
https://developer.mongodb.com/article/atlas-sample-datasets/
A link to directly download all available sample datasets (307 MB): …
Mongo Shell
2021-05-27Using mongo Shell
Mongo shell is an interactive JavaScript interface to perform query and administrative tasks. It can be launched in a command-line interface or operated by other applications.
Launching a mongo shell in command …
Installing MongoDB Server on Ubuntu
2021-05-26Installing MongoDB Community Server on Ubuntu 20.04 LTS
Ubuntu on Windows Subsystem for Linux cannot use this method because systemd is not enabled.
- Import MongoDB GnuPG public key
wget -qO - …
SWOT analysis of MongoDB
2021-05-26What makes MongoDB different?
MongoDB being a document-oriented database, each record is contained in a BSON-formatted document. Without the typical restrictions of a table layout, fields and properties can be inserted and removed anytime, …