Question

When creating database tables I'm often stumped when trying to name my time/date/timestamp fields. Sometimes it's easy, like edit_date and expiration_date... but often it's not as easy. I don't like repeating the table name in the field names because it seems redundant. If you have a posts table, should your timestamp field be post_date? Obviously we shouldn't (can't?) use date/time/timestamp for field names, although sometimes they seem like the best choice if we had the option.

Is there a logical naming convention for naming time-related fields? As this question is probably not definitively answerable I went ahead and wiki'd it from the get-go. Having typed it all out it seems trivial and silly, but hopefully there's someone else out there that has agonized over field names in the past that will sympathize.

Edit:

As a related follow-up question, do you use 'time' or 'date' in your field names when dealing with datetime/timestamp data that has more than just the date component to it (DownloadDate vs. DownloadTime vs. something else)?

Was it helpful?

Solution

The "housekeeping" dates are best named the same in all tables for consistency in the downstream usage, e.g. DateCreated and DateModified. Other dates will be more indicative of their usage and will be particular to an action, e.g. DateInvoiced, DateSold, etc.

OTHER TIPS

CreatedOn, CreateDate, ModifiedOn, ModifiedDate

are a few suggestions

DateCreated DateModified PublishTime UpdateTime LastUpdateTime creationTime modificationTime

These properties are also some of the basic properties ... and they should be in all the tables (there can be exception) ... if you are mapping the tables to objects ... these two should be part of the base class (along with UIDs)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top