databaserestdatetimestamp

Should the "last updated" field be initialized to something?


I'm building a REST API.

My users have created_at and updated_at fields. These fields hold strings that look like this:

"2014-12-29T12:30:21+0000"

When I create a user, I set created_at to the current date. However, I'm not sure if I should do the same for updated_at. Technically, the user has never been updated. But it seems weird for there not to be something there.

Should I leave the value NULL, make it the same as created_at, or do something else?


Solution

  • Creating is updating state (from nothing to something) so it can safely be considered an "update".

    I would set the updated time on creation, if for no other reason than you don't have to cater for null values (ever).