Why use MongoDB
1. It stores the data in JSON format.
2. Full index support.
3. Replication and high availability.
How to Install MongoDB on Linux, Windows and Mac OS
Go to the download page of MongoDB and choose the production release for the operating system you use.
Before going to create our first database with MongoDB let’s first familiar with their terms.
1. Database – It is a set of collections.
2. Collections – Collection in MongoDB is like a table in MySql. But it does not have schema.
3. Document – It is like a record or row in relational databases (like mysql). In mongoDB record is stored in BSON (Binary Json) format.
4. Field – It is similar to column in relational databases .
Creating Database with MongoDB
I assume you have installed MongoDB successfully in your system. Go to the terminal (ctrl + Alt + T) and type mongo and press enter. It opens up a mongo shell.
To check all the database
# show dbs
Let’s insert some records in our emp collection. We have not created any database yet but mongodb creates when record is inserted.
Now the value is inserted successfully, you can check through find() command.
_id field is created by mongoDB automatically. It is the auto-increment field.
To view the output in proper format
In next post i will talk about queries on mongoDB.