MySQL Forums
Forum List  »  Newbie

Re: Different data types
Posted by: Rick James
Date: August 17, 2010 08:43PM

"how does someone create a query that pulls rock weights from 15 to 30 lbs if the data is stored as varchar?"

What are you asking?
1. "How do I store weights that might be in lbs or kg?"
2. "How do I store approximate values, like '15-30 lbs'?"
3. "Given some records with specific values, how do I fetch all values in some range"?

Answers:
1. Convert every thing to standard metric values.
2. That gets complex.
3. WHERE weight BETWEEN 15 and 30 (except that #1 says these need to be converted to kg)

And to repeat Peter's plea: Do not use EAV design!

The compromise for EAV: In the table, store explicitly the columns that you might search on (eg, `weight`). Then have a blob for the rest of the junk. I like JSON for the blob. Your application code would parse the blob to display the other fields.

Options: ReplyQuote


Subject
Written By
Posted
August 17, 2010 11:58AM
August 17, 2010 01:19PM
August 17, 2010 01:29PM
August 17, 2010 01:53PM
Re: Different data types
August 17, 2010 08:43PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.