So I am currently learning Firebase and NoSQL databases. I have a doubt about which to use when I have lots of referenced objects in other objects. I have come up with a solution to hold id
of the referenced object instead of holding the whole object and retrieving it by id
on demand but started wondering which way is more efficient and should be used.
First example is holding id
of an object:
"job": {
"id": 1,
"name": "name",
"orderId": 1
}
When using this method, whenever I get job
object, I also get order
object and attach it to the job.
Another solution is to hold whole object:
"job": {
"id": 1,
"name": "name",
"order": {
"id": 1,
"date": "2022-01-28"
}
}
In this way, there are no problems except that database has huge objects.
Which is better and more efficient to use? Or maybe there is a third way?