Where should I store a foreign key?

Which table is the child in the relationship?
Answer that, and you know which table needs the foreign key column, referencing the parent’s [typically] primary key. That’s for a one-to-many relationship…

A many-to-many would require you to add a third table, using the keys from both of the two tables as it’s primary key.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)