I. Introduction
- MongoDB is an open source NoSQL database management, designed to store a large scale of data and allows to work with data efficiently. (high performance, high availability and easy scalability)
- MongoDB is written in C++.
- It uses collections and documents to store data instead of using tables like traditional relational databases.
- Data is stored in json format called bson.
- MongoDB allows users to save nested documents.
1. Database
- Database is a physical container for collections.
- A MongoDB server can have multiple databases.
2. Collection
- A collection is a set of MongoDB documents, it is the equivalent of an RDBMS table.
- Collections do not enforce a schema which means documents in the same collection can have different fields.
- Documents in the same collection have the related purpose.
3. Documents
- Document is a set of key-value pairs.
- It has flexible schema (they dont need to have the same sets of fields or structure).
- Documents' common field can hold different data types.
4. Example of document
{ _id: ObjectId(7df78ad8902c) name: 'Vivian', gender: 'female', abilities: ['reading', 'speaking', 'eating'], friends: [ { name:'Ann', gender: 'female', }, { user:'Irene', gender: 'female', } ]
}
5. Comparision of RDBMS and MongoDB structure
RDBMS | MongoBD |
---|---|
Database | Database |
Table | Collection |
Row | Field |
Table Join | Embedded documents |
Primary key | default key _id auto-created by MongoDB |
II. Installation & setup
- Go to MongoDB Download Center to download the current version available of MongoDB.
- Open the msi file when the download is completed and click next button.
- Accept the End-USer License and click next.
- Click complete.
- Copy link of Data Directory and click next.
- Click next then install MongoDB and wait for the process to complete.
- Click finish to complete installation process.
- Go to path
C:\Program Files\MongoDB\Server\your-version\bin
where MongoDB installed and copy this path.
-
Create an environment variable.
- open system properties > select environment variables
- choose Path and click Edit
- Click New > Paste the copied path > OK.
-
Open C drive and create folder data and its sub folder db then open command prompt and run
mongod
command. If data is shown, that means the MongoDB run successfully.