This is probably a subjective question, but I would like to know your opinion. It’s somehow related to this question, but I would like to now if you would start off in databases with 0 or 1. Auto-incremental ids in sqlserver start off from 1, so my subjective opinion wouuld be to start off with 1. On the other hand, in most programming languages, indexes start off with 0.
Share
Personally, I would start any ids in the database at 1, not 0. I would then treat 0 as an invalid value for the identity.
The reason for this is that when you deal with objects from the database in code, it is common to have the identity value stored in an integer type field. In some programming languages (I’m speaking with C# and Java experience), the default value for uninitialised integer fields is 0, meaning that if the identity field was not set in code, you would get the same value as that of a row in the database with an identity of 0. This leads to ambiguity and possibly hard to track down bugs.