title: Good pattern for storing ages, in MySQL, without reference to a date of birth
body: <p>I have some data on fatalities which I'm trying to store, and I'm trying to come up with a reasonable scheme for storing the age of the person when they died.</p>
  
  <p>I don't have DoB data for any of them, but I do have date of death generally (although not always very precisely) and I have data of varying accuracy for their age at death.</p>
  
  <p>Some typical source data might be:</p>
  
  <blockquote>
    <p>between 20 and 29 years old (or "in their 20s") <br>
    5 years old <br>
    2 months old <br>
    40 days old <br>
    adult <br>
    child <br>
    elderly<br></p>
  </blockquote>
  
  <p>I have typically been storing this in three fields...</p>
  
  <blockquote>
    <p>age_min (integer years)<br>
    age_max (integer years)<br>
    age_category (enum - baby, child, adult, elderly)<br></p>
  </blockquote>
  
  <p>...but clearly this doesn't capture the 2 months old or 40 days old very well, both of which would simply end up as 0 years in my current schema, which is needlessly throwing away information.</p>
  
  <p>It is very important that the database is honest about the precision to which information is known. So converting 2 months into 60 days, for example, would be a bad thing, because it implies a level of precision the source data didn't provide - converting it into 60-90 days might be ok.</p>
  
  <p>I also considered adding a units field so I'd have...</p>
  
  <blockquote>
    <p>age_min (integer)<br>
    age_min_unit (enum - days, months, years)<br></p>
  </blockquote>
  
  <p>but the problem with this is it makes comparisons annoying. 24 months == 2 years, but dealing with that just makes a lot of code much more complex than I suspect it needs to be.</p>
  
  <p>I could store all ages in days, with a min and a max, but then the complexity becomes converting that back into something human readable which isn't clunky and doesn't express a greater degree of precision than I actually have.</p>
  
  <p>So for example, 40 days might end up being rendered at 1 month, 10 days which is actually a little less precise than saying 40 days.</p>