I’m programming a cloud application that will be deployed around the world (of course, it’s an example).
When my users click on deploy, they’ll choose their preferred region, and if busy, the application will be deployed in a close region.
My question is how I can store/database/use a unique identifier to region? My first idea is use phone code for country (like +55 for Brazil), but I don’t know how to identify a state/province/region of a country (remember that needs to be global).
Here, we use another 2-digit code for region like 51 for south region of Brazil, so, if I need to identify the south region of Brazil, I can use 5551 for a unique identifier, but for other countries?
You are using the words region and country. A region could be something like North or South America. The countries are in the region and on the globe.
You could look up how Google Earth API does it and use their method for determining a region or country.
https://developers.google.com/earth/
and
Region
Additionally you could use the WWW’s norm for each county in the URL suffix, e.g. .us, .ru, etc. that is defined in the ISO 3166-1 alpha-2 to uniquely identify each country:
http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
Hence to uniquely identify a “region” within a country you could use a combination of Region and country code.