Introduction
It is a document-oriented database
Provides high performance, high availability, and easy scalability
It works on the collection and document
Sql Vs Nosql database
In sql database the data model is structured
In Nosql database the data model can be of the following 4 types
Graph Based Database
Document Based Database
Key-Values database
Column family database
The data structure is predefined in sql database
The data structure is dynamic in the NoSql database
SQL database is vertically scalable
NoSQL databases are horizontally scalable
Query Language for SQL database is: MySQL, SQL
A query language for a NoSQL database is dependent on the NoSQL database used
Define property for SQL database is acid
The define propoerty for Nosql data is BASE/CAP
NoSQL Databases
HBASE
Cassandra
MongoDB
Structure Of A MongoDB database
First, we need to create a database that will act like a physical container
The collection group of the document is a collection more like the table schema in sql database
Document is the actual value of collection
Establishing a Connection with MongoDB
import pymongo
# Provide the mongodb localhost url to connect python to mongodb.
client = pymongo.MongoClient("mongodb://localhost:27017/neurolabDB")
# Database Name
dataBase = client["neurolabDB"]
# Collection Name
collection = dataBase['Products']
# Sample data
d = {'companyName': 'iNeuron',
'product': 'Affordable AI',
'courseOffered': 'Machine Learning with Deployment'}
# Insert above records in the collection
rec = collection.insert_one(d)
# Lets Verify all the record at once present in the record with all the fields
all_record = collection.find()
# Printing all records present in the collection
for idx, record in enumerate(all_record):
print(f"{idx}: {record}")