April 7, 2003 at 9:24 am
Which data type would be the best to use for entries with dimesions. Example:
1'3.75"X2'1.25"
Thanks
April 7, 2003 at 10:29 am
I would say varchar. But you could separate the dimension into more columns of decimal or int types. For example: use 1 for one column, then 3.75 in another.
April 7, 2003 at 10:29 am
One alternative is as follows
- Database Structure:
1'3.75"X2'1.25" is a complex datatype. Convert this in to two simple datatypes(length and width)
So define two columns in the table structure length and width both as float or decimal datatype
- Storing Data:
Store the input values as single unit, ie., in your case it is feet.
Convert the inches also to feet to get a single decimal value using transformation 1' = 12''
for example convert 1'3.75" into feet (using 1 + ( 3.75 * 1/12.0)) which gives 1.3125 store this in length
convert 2'1.25" into feet which gives 2.104166 store this in width
So the dimention 1'3.75"X2'1.25" will be stored in database table as 1.3125 in length column
and 2.104166 in width column
- Retrieving Data:
You can format the data using sql formatting to get back 1'3.75"X2'1.25"
- By doing this way you will have advantage of formatting data in the way you want and also you can use this for calculations if required.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy