I'll be storing annually inside a MySQL table: Is it more beneficial to keep this like a smallint or varchar? I figure that becasue it is not really a full date, the date format should not be a solution but I'll include that a lot.

Smallint? varchar(4)? date? another thing?

Good examples:

  • 2008

  • 1992

  • 2053

I'd make use of the YEAR(4) column type... but only when time expected are inside the range 1901 and 2155... otherwise, see Gambrinus's answer.

I'd choose small-int - so far as I understand - varchar would take more room in addition to date. second option is the date.

My very own experience is by using Oracle, which doesn't have annually data type, however i have always attempted to prevent using number data types for elements just since they're composed only of numbers. (Which means this includes telephone numbers, social security amounts, zip codes too, to supplement good examples).

My very own guideline would be to consider exactly what the information is employed for. For a moment perform mathematical procedures onto it then store it as being several. For a moment perform string functions (eg. "Go ahead and take last four figures from the SSN" or "Display the telephone number as (XXX) XXX-XXXX") then it is a string.