7
I downloaded an IBGE xml file with data from states, cities, municipalities and districts. I separated it into 4 tables and made their relationships.
My question is:
- It’s right this relationship I’ve made?
- It has how to improve even using Mysql?
I made a view to make more practical data search with the query displayed.
- This query has how to improve or is already good?
- And when I put one
order by nome_estado, nome_cidade, nome_municipio, nome_distrito
, with the data I have (a total of 10302) this query goes from 0.006s (an average) to 0.356s (tbm an average), because of the order by. There are ways to improve this order?
Follow the query itself:
select e.id as estado_id, e.nome as nome_estado,
c.id as cidade_id, c.nome as nome_cidade,
m.id as municipio_id, m.nome as nome_municipio,
d.id as distrito_id, d.nome as nome_distrito
from distrito d
join municipio m ON m.id = d.municipio_id
join cidade c ON c.id = m.cidade_id
join estado e ON e.id = c.estado_id
Could you tell me the link where you downloaded this XML? I am in great need and I am not finding.
– Marcio Mazzucato
@Marciosimao the link where it is based is this one http://servicodados.ibge.gov.br/Download/Download.ashx?u=geoftp.ibge.gov.br/organizacao_territorial/divisao_territorial/2013/dtb_2013.zip is from 2013, but it was the most current one I found.
– Marcelo Diniz
Thanks for the return! You know if there is any table with the list of neighborhoods of each city?
– Marcio Mazzucato
Dai I don’t know anymore, but I think the closest thing to looking at this table is the district name. Here where I work already served and said I would not need more than that
– Marcelo Diniz