- Data modeling is the process of defining how data is stored and what relationships exist between different entities in our data.
- Data modeling aims to visually represent the relationship between different entities in data. It also seeks to represent the data’s organization and grouping.
Type of modeling :
1. Embedded Documents:-
{
_id: <ObjectId123>,
title: "Data Modelling in MongoDB",
body: "some long text...",
comments: [
{
_id: <ObjectId111>,
comment: "some text...",
author: "mike@email.com"
},
{
_id: <ObjectId222>,
comment: "some text...",
author: "jake@email.com"
}
]
}
---------------------------------------------------------------
2. References:-
// blog post
{
_id: <ObjectId123>,
title: "Data Modelling in MongoDB",
body: "some long text..."
}
// comments
{
_id: <ObjectId111>,
comment: "some text...",
author: "mike@email.com",
postId: <ObjectId123>. // reference to the blog post
},
{
_id: <ObjectId222>,
comment: "some text...",
author: "jake@email.com",
postId: <ObjectId123> // reference to the blog post
}