Is the ZIP code a unique ID in Brazil?

Asked

Viewed 6,702 times

24

I own the official CEP base in Brazil, e-DNE, sold by the post office.

I need to create a new bank from it, and would like to know if I can use the ZIP code value as my DB’s unique identifier.

As there are localities that use the same zip code for several addresses, I would like to know how to identify only these locations.

  • 1

    Put several addresses in it. It has place that is a zip code for the whole city.

  • 8

    Unique identifier of what? What do you consider a "site"? What I do know is that the zip code can be a few blocks or an entire neighborhood (maybe even entire small towns). So if you need to identify something more specific than that, no, it’s no good.

  • It is worth remembering that Zip Code changes with some frequency. Recently my street gained another zip code, and the zip code of where I live has changed. Okay, it’s rare - in 27 years, my address has only changed zip code twice. But take that into account.

  • Look, the zip code itself is unique in the sense that there is no other zip code with the same numbering but I would be afraid to use it as a PK. Post your schema so we can contextualize and give a more accurate answer

2 answers

31


Let’s go back a bit to the theory of primary keys, we should do some analysis: Basic rules for primary keys:

  1. NO TWO occurrences of the same entity with the same content in the Primary Key
  2. The primary key cannot be composed of an optional attribute, or is , attribute that accepts null.
  3. The identifier attributes shall be the minimum set that can identify each instance of an entity.
  4. External keys should not be used. (Attributes about which you has no control. Ex: CPF, CNPJ)
  5. Each key identifier attribute must have a reduced size Shall not contain volatile information.

Let’s start from number 4, where ZIP code is an external key, IE, if it is included some number or there is some modification, how would you act in cases like this? Recalling that recently in the city of São Paulo there was the change in the telephone number. Changes like these in a PK(primary key) would cause many problems. The idea of following the normalizations is to ensure the stability of your database with ACID (Atomicity, Consistency, Isolation and Durability).

You could even facilitate the search using the number of the zip code as INDEX, this would help, however, in this case the best is to keep the PK with a same auto-increment ID.

  • beautiful explanation.

3

Arriving 1 year later, but the intention here is to record the link to the concept of "geographical thing designated by the EPC"... This leads to 2 answers.

Only after having clarity of the object, of the thing that was identified by the ZIP code, does it make sense to ask for example if the thing has changed, or, more importantly, if two ZIP codes would not be pointing to the same thing: if two ZIP codes point to the same thing it is not unique, that is, it cannot be considered a unique identifier.

The typical "thing" pointed out by the Ceps until 1992 was a city or sub-region of city, nicknamed by the Post Office as "Division of Sub-Sector". There was even a map map of CEP regions, that today still worth to map the Generic ceps, those in shape XXXXX-000 (zero suffix)... Answer-1: Generic ceps are always unique, each designating its own region on the map.

The zip code that we are used to today, however, is the one that designates a street, a square or even "the right side of the street section", etc. This type of zip code is called ZIP code (has suffix in the range of 001 to 899). The thing he designates is a "polygon of square faces" (see Wikipedia), that in the illustration below corresponds to a color, (imagine for example. that the CEP 12345-678 designates the colour blue)

So we come up with another possible answer... Answer-2: The Common zip codes are always unique, each designating its "square face region" on the map.

Of topological point of view, However, there is something strange: the areas of the 2-response are within the 1-response areas. From this point of view there is spatial overlap between different Zip Codes, that is, there are two Zip Codes designating the same thing... It can be argued that there is no uniqueness in the CEP as a whole, only when considering only one type of CEP.


There are still the 'special Ceps', which can designate addresses already contemplated by the 'common zip code', but again we have to understand that the 'special zip code', when designating a geographical entity, is an entity within a 'common zip code'... But finally, it can be argued that the special Zip Codes duplicate some of the common.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.