Persisting all data as string is a problem?

Asked

Viewed 147 times

5

Is there any problem in storing all the information of an application like string in the database?

Independent of the application, SGDB, the programming language used, etc. I ask more for data handling issues, in most languages that use string handling is easier.

1 answer

9


Yeah. There’s no way to just manipulate string. Actually, if you do this, it’s gonna be harder since you have to do conversions all the time. Unless you have something that actually only works with text, which is unlikely?

How will you account for string? Can’t.

But you are on the right track if you consider that any information that will not be used in accounts is of the type string. A common mistake that novice programmers make is to store data that is just numbers like ZIP, CPF, Phone, etc. as a numeric type. It really is wrong. Descriptions must be texts, and these data are merely descriptive.

But how to store data like quantity, price, expiration date, etc. as string? This is complication. Not that I can’t do but it will take more work and it will be easier to make mistakes.

This goes for the database or the program itself. There are various types for a good reason. And I actually have my doubts whether to manipulate strings is easier in some language. I won’t say because I think it would just be my opinion.

What you’re trying to do is use a technique called stringly typed in reference to what is officially called strongly typed. And it’s an abomination.

  • 1

    Microsiga’s ERP creates many fields such as "string" that should be numerical, example Billing Year , Billing Month, this creates difficulties of every order (validations, classifications etc.), different types exist because there are different needs. Manipulating numbers as a string is very laborious.

  • 1

    @Mota, some parts do not have this gambiarra, guess who made these parts? : ) And I would do more if this.

  • A possible (and half forced) example would be to save the contents of an imported text file, as "garbage" can be sent so dates, values etc should be saved as string.

Browser other questions tagged

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