-
Notifications
You must be signed in to change notification settings - Fork 3
1.0 Essentials
| RDBMS | MongoDB |
|---|---|
| Database | Database |
| Table | Collection |
| Row | Document |
| Index | Index |
| JOIN | Embedded document, document references or $lookup to combine data from different collections |
Mongo DB supports a hundred levels of depth for your documents
See More: Terminology and Concepts
See More: SQL to MongoDB Mapping Chart
- String− This is the most commonly used datatype to store the data. String in MongoDB must be UTF-8 valid.
- Integer− This type is used to store a numerical value. Integer can be 32 bit or 64 bit depending upon your server.
- Boolean− This type is used to store a boolean (true/ false) value.
- Double− This type is used to store floating point values.
- Min/ Max keys − This type is used to compare a value against the lowest and highest BSON elements.
- Arrays− This type is used to store arrays or list or multiple values into one key.
- Timestamp− ctimestamp. This can be handy for recording when a document has been modified or added.
- Object− This datatype is used for embedded documents.
- Null− This type is used to store a Null value.
- Symbol− This datatype is used identically to a string; however, it's generally reserved for languages that use a specific symbol type.
- Date − This datatype is used to store the current date or time in UNIX time format. You can specify your own date time by creating object of Date and passing day, month, year into it.
- Object ID − This datatype is used to store the document’s ID.
- Binary data − This datatype is used to store binary data.
- Code − This datatype is used to store JavaScript code into the document.
- Regular expression − This datatype is used to store regular expression.

See More: Query Language
See More: SQL to MongoDB Mapping Chart
RDBMS Data
- Separate tables for different data
- Tied together by primary key
- Complex representation
SQL Query for data from RDBMS
- Data is discrete in several tables
- Complex to select


Select data from MongoDB
- Data is in only an object
- Easy to handle

See More: Query Language
- Similar to GROUP BY function in SQL

See More: SQL to Aggregation Mapping Chart
Index
- 64 indexes
- Single field
- Compound
- Unique
Mongo does support up to 64 indexes per collection
Sharding
- Partition data onto different machines
- Provides scalability via software
- Autosharding supported by Mongo
- Challenging to set up
Using sharding means that you can scale your application across several smaller systems rather than investing in a larger, more expensive solution.
While sharding is aimed at scalability, it's arguably even more important to ensure the uptime of your system, and for this, Mongo provides replication.
Replication
- Reliability
- Maximizes uptime
- Replica set
- Automation failover
With MongoDB, you set up a replica set for your database with a primary server and some number of secondary servers, which keep copies of the primary servers data. If your primary server fails, one of the secondary servers will be promoted to the primary slot, and the database will continue to act as usual. When the original primary comes back online, it will be added back to the system as a new secondary server in the system.
db.number.explain("executionStates")

function addNumbers( x , y ) {
return x + y;
}
> db.system.js.save({_id:"addNumbers", value:function(x, y){ return x + y; }});
> db.system.js.find()
{ "_id" : "addNumbers", "value" : function cf__3__f_(x, y) {
return x + y;
} }
> db.eval('addNumbers(17, 25)');
42
GS1 Canada® is a registered trademark of GS1 Canada. Copyright © GS1 Canada 2018.