Thursday, May 25, 2017

MongoDB Introduction and Basics


Big Data
Big Data is a concept to define data as a key value pair structure which provides high scalability and performance for persistence, retrieval, and maintenance. As name stands, it handles large volume data and complex structure easily.
Mongo Database
MongoDB is open source big data type database. Record in MongoDB is a document defined using key value pair. MongoDB is NoSQL database, User need to use MongoDB Shell and MongoDB syntax to create database, insert document, and query the data.
MongoDB document would be
{
 "fieldName1": "value1",
 "fieldName2": "value2",
 "fieldName3": "value3"
}
There are some rules for field names:
  • “id” is reserved for Primary Key field.
  • Field name has to be unique in a document.
  • Field name should not start with null, $.
  • Field name should be alphanumeric.    
Basics
MongoDB comprises databases > collections > records as listed order in BSON format. Collection will have 1 or more number of records, Database will have 1 or more Collections, and there can be 1 or more databases.  
Structure would be:         

Commands:
To create new database Use  

To insert new record in a collection: db..insert(<{structure}>})
To insert one record in a collection: db..insertOne(<{structure}>})
To insert many record in a collection: db..insertMany(,
     

To find record in a collection: db..find()
To find one record in a collection: db..findOne()

When we insert a record into collection, MongoDB will create database and collection if it doesn’t exist.   

User has to connect to MongoDB Shell, and insert record.

No comments: