I believe there is no correct answer either in RDBMS (SQL) or Nosql. The design of the data will always depend on the purpose of your system.
If you are developing something that catalogues geographic entities (cities, streets, neighborhoods) like Google Maps or some delivery service, then it may make sense to ultra-normalize to the level of street and block.
On the other hand, if you’re just collecting customer addresses, and just need a single address, like Address of Collections, it would be much simpler to put the fields addressee, neighborhood, city, UF, parents in the client’s own table.
Similarly it is in Mongo. You can store collections of cities, neighborhoods, etc (ex: a neighborhood {_id:1, nome: 'Centro', cep: '12345-123', id_cidade: 123}
) and make reference in another collection (ex: client {_id: 456, nome: 'Restaurante da Praça', endereco: {rua: 'Av Tancredo Neves, 333, sala 14', id_bairro: 1} }
). Or you can just nest everything (e.g., customer {_id: 456, nome: 'Restaurante da Praça', endereco: {rua: 'Av Tancredo Neves, 333, sala 14', bairro: 'Centro', cidade: 'Patópolis', uf: 'XY', pais: 'Disney World', cep: '12345-123'} }
).
In both cases (relational x nosql) there are advantages and disadvantages. It is up to you to analyze factors like: how and how often these data will be accessed and modified, impact on application performance, data maintenance difficulty, disk size, etc.
My advice tends to side with start simple, revisit, and Refine if you need to.
Remove the Node.js tag from your question, your question is unrelated to this technology.
– Luís Fernando Guedes
Why is there no connection with this technology? There can be something related to it that my practice is not recommended, such as server bottleneck, or something else. Ok I removed the tag.
– David Jesse