I have a table in MySQL with a field of type DATE for storing some dates, and I have another table in which I have a field of type SMALLINT for storing only a year.
Now I need to differentiate between a date (or a year) that is simply unknown from a date (or a year) that hasn’t occurred yet. It’s pretty straightforward that unknown values should be NULL. But is there any recommendation as to what value to use to store dates that haven’t yet occurred with the types I mentioned?
I’m quite sure that no dates / years before 1000 will ever be used, so I could use e.g. 0000-01-01. Is there any better / recommended solution?
EDIT Just read that for the DATE type “The supported range is ‘1000-01-01’ to ‘9999-12-31’.” So I would have to use 1000-01-01 instead of 0000-01-01.
It sounds like you are trying to use one column to store two separate bits of data. Whether someone is dead or alive (effectively a status field) and the date on which they died are separate bits of info. As such, I’d suggest you store them separately. Whether someone is alive or dead without the date of their death being known, the date of death is NULL in either case. I wouldn’t use the date field to determine whether or not they are dead. Thus I would suggest a TINYINT (or BOOL) column to store whether they are alive or not and a NULL-able DATE field for their date of death.