2.5 KiB
2.5 KiB
title |
---|
MongoDB |
MongoDB
MongoDB is an open-source non-relational database that uses a JSON-like structure to store data. It uses a document model to store and retrieve the data instead of the table model used by relational databases such as SQL or Oracle.
MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use. MongoDB in applications built with javascript is mainly used with Mongoose which is a package built on top of native mongo driver . It gives features like schema based design , virtuals , data validations etc. It makes the mongodb experience smooth and easy to use. You can learn more about mongoose here.
NoSQL Vs RDBMS
MongoDB Terms And Concepts | SQL Terms and Concepts |
---|---|
Database | Database |
Collection | Table |
Document | Row |
Field | Column |
Index | Index |
Embedded Documents | Table Joins |
MongoDB Characteristics
- Next Generation Database
- No Joins
- Clustering
- Opensource
- Schema-Less
- No Relationships
Features of MongoDB
- Document Database
- High Performance
- Rich Query Language
- High Availability
- Horizontal Scalability
- Supports Indexing
Cons of MongoDB
- Schemaless design requires database manager to ensure certain constraints
- Indexing on multiple fields takes more memory
- Aggregation queries are at times non-intutive
Sample Document Structure
{
"_id":ObjectId("52ffc33cd85242f436123532"),
"name": "Rich Rick",
"contact": "8826078979",
"dob": "11-04-1997",
"address": [
{
"building": "24 A, Indiana Apt",
"pincode": 123456,
"city": "Los Angeles",
"state": "California"
},
{
"building": "170 A, Acropolis Apt",
"pincode": 456899,
"city": "Chicago",
"state": "Illinois"
}
]
}