How to store unit quantity and type in MySQL?
I'm not really sure how to articulate this question. So please point me in the right direction if this has already been answered.
Basically I want to store the unit types so that I can do some comparison later based on user selection. For example, user can select "day", "week", "month", "year" as a unit type. Then they need to select a number associated to that unit type. Having this number and the unit type will allow my program to do some calculation based on user selection.
Another example is for selecting other unit types like metrics and imperial that is, mm, cm, m, km, or inch, feet, mile, etc etc...
Do I just store them as varchar and then just do a string comparison in my program?
Varchar is always the option of last resort. Try and create a numbering system for it like with ids. So, you could have another table for relationships that would have the text value like "day","month", etc matching the numbering system.