Hello, first of all, you should forget the logic of working in SQL databases and go on to interpret the instances of the classes in which it works directly, this is the logic of nonrelational databases of document type (eg: Firebase, Mongodb, Mariadb, etc...).
When working with this type of database, objects are instantiated directly, according to their elements. In the case of firebase (which is your choice) it does not allow working directly with arrays within objects, instead it allows you to define the Keys for a parent object in an orderly fashion. The result would be something like this:
{
"carros": {
1: { "nome": "carro", "unidades": 1 },
2: { "nome": "carro2", "unidades": 3 },
3: { "nome": "carro3", "unidades": 5 },
}
}
With this structure, you no longer need to keep the "id" of the table within the object because it is only a relational index and is no longer a logical reference. If it is necessary to use, firebase allows, in the query you tell it to also send the key $key
for your object, which will be identified directly as if it were your "id".
I advise you to start studying No-SQL because from now on it is the future regarding the storage of data in question at cost/benefit. Even well-used and robust databases like Oracle and MS Sqlserver are not comparable to No-SQL databases when you have massive data processing and a large mass of simultaneous connections.
There is a sequence of videos with excellent explanations about this: Click [here](https://www.youtube.com/watch?v=noB98K6A0TY "Getting Started with the Firebase Realtime Database on the Web, Part 1")! And the documentation also [here](https://firebase.google.com/docs/database/web/start "Firebase Database ")!
– Felipe Cardozo
https://firebase.google.com/docs/? hl=en The firebase documentation itself teaches everything very easily and intuitively
– Mateus