I was wondering, if we have two tables that share one column in common and in the first table this column is a primary key but in the second, another is chosen as a primary key… then does SQL treat the common column in the second table as just another ordinary column? Hence no optimization is present if the second table is searched based on the common column info, i.e. primary keys between two related tables are completely independent?
Share
Yes they are independent: primary keys are completely unique to a table.
They are not shared across tables, even if the type of the column is the same, but you can share the primary key of a table as foreign key in another table.
No optimization is performed, as the second column you had mentioned is not a primary-key in that table. And the database by default creates an index based on a primary key which improves looking up in the table data.