Are there any repercussions using Negative Primary Keys for tables (Identity Increment -1, Identity Seed -1 in SQL Server 2005)?
The reason for this is we're creating a new database to replace an existing one. There are similar tables between the two databases and we'd like the "source" of the information to be transparent to our applications. The approach is to create views that unions tables from both databases. Negative PKs ensures the identities don't overlap.
No there's nothing inherently wrong with negative values in a primary key.
You cannot just enter any value in a FK field, the value you enter (negative or not) MUST exist in the referenced table.
Primary Key Example The student's first and last name are not good choices because there is always the chance that more than one student might have the same name. Other poor choices for primary keys include ZIP code, email address, and employer, all of which can change or represent many people.
Did you know that Identity Value can have a negative value?
Like others have said, the database is fine with this.
But it would be a problems for a .NET application that uses DataSet+DataAdapter as they use negative keys as temporaries for new records.
Other data-access layers may use similar tricks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With