I was recently tasked to perform some modifications to a backend system written by another developer who is no longer available. Best practices dictate generating a complete database backup before performing any database operations, which is fortunate, because he left some Easter eggs in his design which I did not anticipate — he used MySQL TIMESTAMP fields.
I can see his intent — his intent was to save coding by setting a timestamp automatically for each record when inserting it into the database. The TIMESTAMP field he used was named “date,” which I have another problem with — it’s not a specific-enough field identifier. I learned by investigating the rest of the code that “date” means “date this record was added.” What he did not anticipate was the possibility of adding new fields to the database, which was my task.
Not realizing he had used TIMESTAMP fields, I simply created a new column in the database to house the new information needed by the client’s application updates. Imagine my surprise when all of the “date” fields changed to today’s date. Because that’s what TIMESTAMP fields do in a MyISAM table — update any time the record itself is modified. Ack. Surely I can imagine reasons for using such a field, but only when that behavior is specifically desired or required, as in a “last modified” field. Using that type of field for a “date added” field is absolutely insane, IMHO. YMMV.