MongoDB vs SQL Terminology
MongoDB is a NoSQL product so the terminology is used in SQL not used in MongoDB, but the comparing SQL things with NoSQL will speedup the learning process.
Terminology | Description | |
1 | field | A name-value pair. It is similar concept of column of an RDBMS |
2 | document | A group of fields are termed as document. In RDBMS we will term it as row. MongoDB document follows JSON syntax but it is a BSON syntax (BSON is an extended version of JSON implemented by MongoDB). |
3 | collection | A group of documents called collection in MongoDB. A collection is similar concept of table of an RDBMS. |
4 | database | A Physical Container for Collections. Each database gets its own set of files on the file system. A single MongoDB server typically has multiple databases |
Let’s view this Table presents the various SQL terminology and concepts and the corresponding MongoDB terminology and concepts.
SQL Terms | MongoDB Terms | |
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. | primary key In MongoDB, the primary key is automatically set to the _id field. | |
aggregation (e.g. group by) | aggregation pipeline |
SQL Concepts | MongoDB Aggregation Operators | |
---|---|---|
WHERE | $match | |
GROUP BY | $group | |
HAVING | $match | |
SELECT | $project | |
ORDER BY | $sort | |
LIMIT | $limit | |
SUM() | $sum | |
COUNT() | $sum | |
join | $lookup |
Executables Comparison
The following table presents some database executables and the corresponding MongoDB executables. This table is not meant to be exhaustive.
MongoDB | MySQL | Oracle | Informix | DB2 | |
---|---|---|---|---|---|
Database Server | mongod | mysqld | oracle | IDS | DB2 Server |
Database Client | mongo | mysql | sqlplus | DB-Access | DB2 Client |