RDBMS mapping terminology
Advantages
Data Modelling
Demonstration
Aggregation
| RDBMS | MongoDB |
|---|---|
| Database | Database |
| Table | Collection |
| Tuple/Row | Document |
| column | Field |
| Table Join | Embedded Documents |
| Primary Key | Primary Key (Default key _id provided by mongodb itself) |
Schema less
No complex joins
Structure of a single object is clear
Conversion / mapping of application objects to database objects not needed
Combine objects into one document if you will use them together.
Duplicate the data (but limited).
Do joins while write, not on read.
Optimize your schema for most frequent use cases.
Do complex aggregation in the schema
RDBMS
MongoDB
C:\mongodb\bin>mongod.exe --dbpath
"D:\workspace\mongodb\data"C:\mongodb\bin>mongo.exedb.help()db.stats()use DATABASE_NAMEdb.createCollection(name, options)db.employees.insert({"name" : "Su Tran"})db.COLLECTION_NAME.find()db.mycol.find({"likes":{$lt:50}})where likes < 50is equivalent to RDBMS Where clause
db.mycol.find({key1:value1, key2:value2})RDBMS
AND
Mongo query
db.mycol.find({$or:
[{"name":"Tuan"},{"name": "Su"}]})OR
{$lt:50}{$lte:50}{$gt:50}{$gte:50}{$ne:50}Aggregations operations process data records and return computed results