MongoDB is an open-source document database, and the leading NoSQL database. Written in C++, with many great features like map-reduce , auto sharding, replication, high availability and etc.
- MongoDB works on concept of collection and document.
- Stores JSON-style documents with flexible schemas represented as (BSON -> Binary JSON).
- Built for Speed
- Rich Document based queries for Easy readability.
- Full Index Support for High Performance.
- Replication and Failover for High Availability.
- Auto Sharding for Easy Scalability.
- Map / Reduce for Aggregation.
- MongoDB stores documents (or) objects.
- Embedded documents and arrays reduce need for joins. No Joins and No-multi document transactions.
MongoDB Designs Goals
Terminology and Concepts
The following table presents the various SQL terminology and concepts and the corresponding MongoDB terminology and concepts.
SQL Terms/Concepts | MongoDB Terms/Concepts |
---|---|
database | database |
table | collection |
row | document or BSON document |
column | field |
index | index |
table joins | embedded documents and linking |
primary key
Specify any unique column or column combination as primary key.
|
In MongoDB, the primary key is automatically set to the_id field.
|
aggregation (e.g. group by) |
aggregation pipeline
See the SQL to Aggregation Mapping Chart.
|
The MongoDB examples :
assume a collection named users that contain documents of the following prototype:
1.
{
_id: ObjectId("509a8fb2f3f4948bd2f983a0"),
user_id: "abc123",
age: 55,
status: 'A'
}
assume a collection named posts that contain documents of the following prototype:
2.
{
‘_id’: ‘3432’,
‘author’: DBRef(‘User’, 2),
‘title’: ‘Introduction to MongoDB’,
‘body’: ‘MongoDB is an open sources.. ‘,
‘timestamp’: Date(’01-04-12’),
‘tags’: [‘MongoDB’, ‘NoSQL’],
‘comments’: [{‘author’: DBRef(‘User’, 4),
‘date’: Date(’02-04-12’),
‘text’: ‘Did you see.. ‘,
‘upvotes’: 7, … ]
}
No comments:
Post a Comment