2

What is the correct way to store phone number data after applying a new mask for user input (example for UK; 44 07400 123456) if the type of the existing column is character varying(32)? Does storing it as it is generated by mask has a drawbacks (especially space characters)?

In other words, what are some pros and cons of storing it as formatted or unformatted might be better to asking for my case, since I'm not dealing with the type of the column and I'm going to stay with the same type. Especially, what I'm really care about is that is, what would be best practice? +4407400123456 or 44 07400 123456 (with spaces).

MDCCL
  • 8,530
  • 3
  • 32
  • 63
esilik
  • 135
  • 1
  • 6

1 Answers1

4

Generally speaking, the presentation layer is where formatting should occur. If spaces are only useful for presentation to the user, then reformat the phone number in the client app, and remove the spaces prior to storing them, since that will save space in the database.

Some of the questions about how to store phone numbers have been asked and answered here already. See this and this.

Hannah Vernon
  • 70,928
  • 22
  • 177
  • 323