A
A
AJ2013-01-10 14:00:15
Database
AJ, 2013-01-10 14:00:15

What to bind to when creating a base of cities?

Good people.
There is such a problem. To bind locations to countries / regions / cities, you need to bind independent codes in order to subsequently store only the code of the country / region / city (the nearest one) in user parameters.
With countries, everything is clear. They have ISO and Alpha codes. The telephone number was dropped immediately, as it turned out that Kazakhstan also had +7. By region, it is also clear. In some countries, you can link to the car code by regions, in some there are postal sections. In general, I got stuck at the time of the classification of cities attached to Moscow. Mytishchi, Khimki, Zelenograd have the same telephone code, the same car code as Moscow.
Now the extreme option is to knit to the starting index of the city. But there is no particular desire. If anyone has experience on the issue, please let me know.
Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ruslan Leviev, 2013-01-10
@2ball

I'll add to rasstroen 's answer . KLADR has long been a thing of the past and instead of it a more adequate, complete FIAS has appeared . In it, you need the ADDROBJ table. The fields in this table that have values ​​for you:
AOGUID - a unique object identifier in the database
PARENTGUID - a unique identifier of the parent object (i.e. AOGUID region, region)
AOLEVEL - the level of the object in the hierarchy, in accordance with the documentation . You need AOLEVEL = 4 - these are cities. But keep in mind that Moscow and St. Petersburg have AOLEVEL = 1, because these are cities-subjects of the Russian Federation.
REGIONCODE - region code (does not match the car, please note)
ACTSTATUS- select only records with the value actstatus = 1. All others are already inactive records, saved in the database for the history of changes.
You can also take the SOCRBASE table - there are decoding of the abbreviations used in the database (r - city, urban-type settlement, etc.)

R
rasstroen, 2013-01-10
@rasstroen

in Russia - KLADR
House code according to KLADR 0100000100000000001
Adygea - 01000000000000
Moscow 7700000000000
(the first 2 digits - region)
Zelenograd - 7700000200000 (Moscow region, dvoechka appeared) Using
any code, you can return the hierarchy to the region, very convenient. Bases in the public domain

I
IDVsbruck, 2013-01-10
@IDVsbruck

Interesting. But is there something similar for Russia?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question