The structure of both (Realtime Database and Firestore) is more or less the same, so I will respond from one but that can be used for the other. Read the documentation for more details
If you want to maintain the same SQL structure, basically you will use a root-level structure, for example:
{
empresa: {
id_empresa_1: {
nome: 'fulano',
categoria: {
id_categoria_1: true,
id_categoria_2: true
},
cidade: 'id_cidade_1'
}
},
categoria: {
id_categoria_1: {
nome: 'beltrano'
}
},
cidade: {
id_cidade_1: {
nome: 'ciclano'
}
}
}
"Translating" pro SQL, the objects at the root level (emrpesa, city and categories) are tables, each object within them is a row of the respective table and the keys of this object are the columns
But you can simplify company objects using a city object within the company object:
{
empresa: {
id_empresa_1: {
nome: 'fulano',
categoria: {
id_categoria_1: true,
id_categoria_2: true
},
cidade: {
nome: 'ciclano'
}
}
},
//...
}
But this causes a nesting of the data and this should be used with caution, although simplifying the structure, it can hinder (and even disable) more complex queries