I am setting up a real estate register, where these properties belong to an address, which belongs to a neighborhood that belongs to a city.
Ex tables:
Imoveis: id, endereco_id, etc...
Enderecos: id, nome, bairro_id, rua, numero, cep, etc...
Bairros: id, nome, cidade_id
Cidades: id, nome;
However, if I want to search real estate in a registered city, how does this relationship work, is it valid to duplicate the key within Real Estate, creating a ciudad_id?
First situation: When searching in selects, I want to list only the cities that have registered properties.
Second situation: Select the city and list ahax neighborhoods that have a property registry.
Third situation: search the properties and list together with them, their addresses, neighborhood and city.
Any idea how to work this data better, and if I'm on the right track?
Note: I'm not asking for the ready queries, but ideas on how to best implement this relational model, where the registration of each neighborhood and city will be done along with the other information of the property, consistently saving the names of neighborhoods and cities, avoiding the duplication of the cadastre of these.