For various reasons I have decided to use surrogate keys (in the form of a seed identity). My question comes from enforcing data uniqueness . For example, take the scenario I am creating a Database to store all the books in a library.
An isbn is a unique identifier assigned to all books from some magic source in the book publishing world. If the book is printed it has 1 isbn if it is electronic it has another ISBN.
We cannot enforce uniqueness on the ISBN without putting a uniqueIndex covering the printedISBN and ElectronicISBN column. The specific question I have is , We have this type of scenario and we need to enforce uniqueness of data but we are using a surrogate primary key, the only way we have to enforce data uniqueness is by putting a unique index on the columns we would like to enforce. This seems counter intuitive because if we followed the surrogate key methodology throughout our design every table would have a surrogate primary key and a unique index?? This seems bad and I feel my design skill is not strong enough to find the “right answer”. What is that answer in these types of scenarios?
BookID INT IDENTITY (1,1) not null,
Title varchar(25) not null,
Author varchar(25) not null,
PrintISBN char(13) not null,
ElectronicISBN char(13) not null