Tipo de modelo de datos MongoDB
- 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: "[email protected]"
},
{
_id: <ObjectId222>,
comment: "some text...",
author: "[email protected]"
}
]
}
---------------------------------------------------------------
2. References:-
// blog post
{
_id: <ObjectId123>,
title: "Data Modelling in MongoDB",
body: "some long text..."
}
// comments
{
_id: <ObjectId111>,
comment: "some text...",
author: "[email protected]",
postId: <ObjectId123>. // reference to the blog post
},
{
_id: <ObjectId222>,
comment: "some text...",
author: "[email protected]",
postId: <ObjectId123> // reference to the blog post
}
jatin kabariya