Data is stored as collections of documents, usually in JSON format.
The database schema is absent.
If candies are needed independently of the owning cat, we would prefer to store them in a separate collection, referencing specific candies in the cat document by their identifiers.
Document
cat
{
"_id": {},
"name": "Cat Astronaut",
"age": 4,
"candies": [
{
"$oid": "647747066566feb9b8618b5c"
}
]
}
Document
candy
{
"_id": {
"$oid": "647747066566feb9b8618b5c"
},
"name": "Cosmic Freshness",
"taste": "Mint",
"filling": true
}
If we are only interested in a cat together with the candies it owns, we can store its candies in
an embedded form directly inside the cat document.
{
"_id": {},
"name": "Cat Astronaut",
"age": 4,
"candy": [
{
"name": "Cosmic Freshness",
"taste": "Mint",
"filling": true
}
]
}