Data ModelΒΆ
The Data Model used by MongoDB has the following hierarchy.
- A Mongo system holds a set of databases
- A database holds a set of collections
- A collection holds a set of documents
- A document is a set of fields
- A field is a key-value pair
- A key is a name (string)
- A value is a
- basic type like string, integer, float, timestamp, binary, etc.,
- a document, or
- an array of values
One way to see this data model is through a mapping from SQL concepts into MongoDB concepts.
MySQL term | Mongo term |
---|---|
database | database |
table | collection |
index | index |
row | BSON document |
column | BSON field |
join | embedding and linking |
primary key | id field |
group by | aggregation |