What is the correct type to store phone and address?

Asked

Viewed 1,096 times

0

As the title says, what is the correct type and correct way to store phone and address, according to database normalization?

  • In the case of phone, what is the correct type to store, the landline and mobile phone? With mask formatting or not?
  • And in case of address, how to store it? In several other fields such as street, neighborhood, number and city, or all in one/two only?

1 answer

0

In the case of telephone, what is the correct type to store, the landline and mobile phone? With formatting mask or not?

It varies from programmer to programmer, but in my case I always do with mask formatting to make it easier to read the data or even return it. About storage I usually create Two tabelas one for fixed and one for cell and I use the chave estrangeira user in order to link.

And in case of address, how to store it? In several other fields such as street, neighborhood, number and city, or all in one/two only?

For this one I like to make the following architecture

inserir a descrição da imagem aqui

Notice that I’m dismembering each address field in a table. And when it comes to putting everything together I use a inner join.

BS.: I used a clear example that you can put up ZIP code, add-on etc.

  • I found interesting the way you did, but this way there is the need for prior registration of the States, Cities and Neighborhoods to be able to create an address. Does this generate any criticism from the user? How did you get around the question of these previous registrations? I’m trying to imagine the usability of frontend, where I see that we have to have the easiest possible.

  • So the best thing at least is to take a database of all cities and states at least because you will not make the User type something that does not fit in one of the fields and makes it not have duplicity of fields (Ex. Campinas , CPS , campinas). About the acceptance for the user is normal since some time ago it was done so the registration of purchases of the American stores. An idea since it is making Web there are some API’s that when placing the zip code it already fills the most important fields for the User. If you know how to handle API’s it will be easy to do this.

Browser other questions tagged

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