Suppose I have a table Books with columns Book_ID (Primary Key), ISBN (Unique), and several others such as Title/author/etc.
I have another table Sales, with primary key Sale_ID, a foreign key to link to Books, and other fields with info on Sales. Sales only exist for books with ISBNs. Is it better database design to have Book_ID or ISBN be the primary key. Note: I will be LEFT JOINing Sales to Books on whichever the foreign key is chosen.
UPDATE: Some Books have no ISBN’s because they’re not published with them. However, I don’t foresee (at least in the next several years) users being able to sell them, because I have no system for making sure that a given book w/o the ISBN isn’t repeated.
In general, I think I would go for the surrogate primary key
book_idas the foreign key.There are a few potential issues that I can identify if you were to use the non-primary key
ISBNas a foreign key:ISBNfor a particular book. What would you do in case there is a sale of that book?ISBN. To edit it, you would have to update all the tables that would be using it as a foreign key.ISBNin the future. Why are you storing books without anISBNin the first place?book_idshould be much more compact than one on anISBNfield.