Database name convention: DATETIME column

2020-05-19 02:28发布

What is your naming convention for DATETIME columns (in my case, using MS SQL Server)

For a column that stores when the row was created CreatedDatetime makes sense, or LastModifiedDatetime.

But for a simple table, let's say one called Event, would you create columns called:

EventID,                 // Primary key
EventDatetime,           // When the event is happening
EventEnabled             // Is the event is on

or

ID,                      // Primary key
Datetime,                // When the event is happening
Enabled                  // Is the event is on

If you'd use neither convention: Please provide the column name you would use.

9条回答
▲ chillily
2楼-- · 2020-05-19 03:00

there are many good answers here, so I won't duplicate. But remember don't ever name a column a reserved word!!!

also, I really like the column names in option 1.

查看更多
SAY GOODBYE
3楼-- · 2020-05-19 03:01

I would likely use something like "WhenRaisedUtc".

查看更多
The star\"
4楼-- · 2020-05-19 03:07

I'd call the column HappensAt, because the row describe an event and the attribute (column) in question details when it happens. As a general rule I try to name my tables with singular nouns and my attributes with phrases that can be used to read, like

tablename(key) columname columnvalue

So I would then be able to say

event(131) HappensAt Dec 21, 2009, 21:30

However this isn't an inviolable rule. I'd still record the date someone was born in a BirthDate column, not a WasBornOn column. You have to bear in mind the common usages of natural language when you name things. Strive for natural usage and the rest will follow. Follow rules blindly and your readers will struggle for comprehension.

查看更多
登录 后发表回答