Good day everyone,
First of all, I am fairly new to RoR and am currently reading "Agile Web
Development with Rails" book to get me started. I guess I am a little
confuse as why we are encouraged to use "ID" as a PK for most, if not
all, our tables. In the book page# 206 (for those who has one), it talks
about why ORDER table has a PK of ID instead of something such as
order_number and some other meaningful column. Could someone explain to
me why using "ID" as PK is a better solution than let's say combining
PKs from 2 different tables for a linking table?
The book provides an example and reasoning for why we should use "ID"
versus "ISBN" number as a PK for a table "BOOK". It says that if the
ISBN formating were to change (assuming there is another table that
reference rows in book table), we will have to drop the FK constraint,
then update the ISBN in both tables and finally recreate the FK
constraint. I seriously thought that this constraint is the point of
implementing relationship between tables so that people cant just go in
to the DB and start changing ISBN number without doing all the dropping
FK, updating ISBN, etc?
Please advise and thank you in advance,