Contents of page >
MongoDB is a open-source document database.
MongoDB is NoSQL database.
1) What are difference in terminology in MongoDB and RDBMS >
MongoDB
|
RDBMS
|
database
|
database
|
Collection
|
Table
|
Document (or BSON document)
|
Row
|
Field (each document can have different fields)
|
Column (each rows cannot have different columns)
|
Embedded documents
|
Join in table
|
_id is the default Primary Key (which is generated automatically whenever document is inserted)
|
Primary Key
|
aggregation (e.g. group by)
|
aggregation pipeline
|
2) Terminology which are same in MongoDB and RDBMS >
MongoDB
|
RDBMS
|
database
|
database
|
index
|
index
|
3) Executables name in MongoDb vs RDBMS >
MongoDB
|
MySQL
|
Oracle
| |
Database Server
|
mongod
|
mysqld
|
oracle
|
Database Client
|
mongo
|
mysql
|
sqlplus
|
4) What is Database in MongoDB?
One MongoDB server can have multiple databases.
Each database has its own collections.
5) What are collection in MongoDB?
Collection in MongoDB is same as table in RDBMS.
Each collection has its own documents.
6) What is Document in MongoDb?
Document in MongoDB is same as row in RDBMS.
Document is set of key-value pairs in collection in MongoDB.
Each document have its own fields.
See below example of documents.
7) What is field in MongoDb?
Field in MongoDB is same as column in RDBMS.
Each document have its own fields.
Important and really interesting thing to note about document in collection is that each document can have different fields.
In RDBMS each table has its own rows but rows cannot have different columns.
See below example of fields.
8) Example of collection, document and fields>
> db.employeeTable.insert({id : 1, firstName:"ankit"})
> db.employeeTable.insert({id : 2})
|
Above line will create table (or collection) (if table already exists it will insert documents in it).
> db.employeeTable.find();
|
Now, query collection.
Output >
Important and really interesting thing to note about documents in collection is that each document have different fields.
Field _id which primary key inserted automatically.
- Document 1 has three fields.
- Document 2 has two fields.
SUMMARY>
So in this mongoDB tutorial we learned
Important difference in terminology in MongoDB and RDBMS >
MongoDB
|
RDBMS
|
Collection
|
Table
|
Document
|
Row
|
Field
|
Column
|
_id is Primary Key
|
Primary Key
|
Labels:
MongoDB