So I am looking to store a date in my SQL database and am not sure what the most efficient way would be. I have thought of two different methods.
Firstly, people are going to be able to set a certain price for each day.
For example:
March 8, 2011: $1
March 9, 2011: $2
March 10, 2011: $5
For my database I was thinking of either storing a UNIX timestamp or storing in the month, day, and year in separate fields.
First method:
UNIX Timestamp
Pros
Cons
Month/Day/Year
Pros
Cons
With the above information, what would be your recommendation? (I can clarify if any of this is not clear.)
timestamp/datetime/date fields are more efficient (they are all stored as integers).
So search is much faster on that.
There is a small (very) overhead of the conversion between different date formats, but, unless you join by date fields (which is ...usually... not smart) you have no issue, it will happen only once.
I do not see how it is error prone.