Document data model
The document data model is a way of structuring and storing data where information is kept in self-contained, flexible documents. The document data model provides the following benefits:
- Self-contained documents: You can model your schema so each document stores all related data together, which reduces the need for complex joins.
- Flexibility: Documents can have varying structures and data types.
- Embedded data: Documents can contain embedded objects and arrays, which enables you to easily model complex entity relationships such as one-to-many and many-to-many.
The following sample document illustrates MongoDB’s document data structure:
{
"_id": ObjectId("650d9b7fb6a6f4f8d45ce0b8"),
"username": "johndoe",
"email": "johndoe@example.com",
"profile": {
"firstName": "John",
"lastName": "Doe",
"...