I am currently reading the book “SQL Programming Style” wrote by Joe Celko.
In the first chapter, at the paragraph “Develop Standardized Postfixes” he states for the id column :
“_id” = identifier. It is unique in
the schema and refers to one entity
anywhere it appears in the schema.
Never user “>table_name<_id”
Few pages later he states
Do not use an underscore as the first
or last letter in a name. It looks
like the name is missing another
component.
He deprecated “id” as column name.
So I would like to know how you guys name the id column ?
I know that most people might think what the point of this question, but I am looking on standardizing my data model, following industry standards and ISO standards as much as I can.
Rather than share my opinions on naming standards, I’ll attempt to answer your question 😉
I think the point Celko is making is that student_ID in a table of students is a code smell i.e. it could be that the designer’s style is to always adds an ID column, probably an auto-increment column, to every table they create in the physical model (even when there is no such column in the logical model) with the intention of using these ID columns for foreign keys. In other words, Celko does not want you to always use surrogate key, rather he wants you to use natural keys where appropriate.
If you read on to section 1.2.5 (p14-15) and follow his rules for table names, you’ll discover why table name + _ID an unlikely occurrence:
So, for example, if you had a table containing student data it may be called Students rather than Student but more likely to be Enrolment (or similar). And a table containing one and only one row is unlikely to need an _ID column.
I suppose there are nouns for whom the plural is the same as the singular so maybe Sheep_ID is acceptable (but only in absence of an industry standard ovine identifier, of course!)
Also consider the rule 1.3.2. (p19) Avoid Names That Change From Place to Place e.g. the same domain referred to in the Students table as ID and in other tables as student_ID. It is unlikely that there will only be one element named _ID in the entire schema!