Do all data persist as string is a problem?

Posted on

Question :

Is there a problem in storing all the information in an application as a string in the database?

Regardless of the application, the SGDB, the programming language used, etc. I ask more about data handling issues, in most languages I use manipulating strings is easier.


Answer :

Yes. There is no way to just manipulate string . Actually doing this will be more difficult since you will have to do conversions all the time. Unless you have something that really only works with text, which is unlikely?

How will you do accounts with string ? It does not work.

But you are on the right track if you consider that any information that will not be used in accounts is string . A common mistake beginner programmers make is to store data that is just numbers like Zip Code, CPF, Phone, etc. as a numeric type. This is really wrong.

But how to store data such as quantity, price, expiration date, etc. as string ? This is a complication. Not that you can not do it but it will give you more work and it will be easier to make mistakes.

This applies to the database or to the program itself. There are several types for good reason. And in fact I have my doubts if manipulating strings is easier in some language. I will not say because I think it would be just my opinion.

What you are trying to do is to use a technique called stringly typed in allusion to what is officially called strongly typed . And this is abominable.


Leave a Reply

Your email address will not be published. Required fields are marked *