When creating a table, there is an option for us to set the numeric primary key as autoincrement where its value increases whenever a new data in inserted.
This primary number can be used for setting the relationship of a table where it is assigned as a foreign key to that table.
So my question is it a good practice for us to use the autoincrement numeric primary as foreign key or should we use the programmatically generated code.
e.g.
for a table products
we have the fields id
(autoincrement primary key), productCode
(program generated unique item code. field property also set to unique), Description
. and we are going to create a relationship to a transactions table. What field should be used as foreign key: autoid
or productCode
?