Technically it works with any of the forms. You should check which of the two forms provides the best index
on the bench. This will depend on the queries that are launched in the database, so you need to analyze the applications that connect in this database and see what queries they usually launch.
For example, if the application usually needs to get the product from a certain standard packaging, the following query will repeat quite a lot:
select * from produto where id_embalagem_padrao = 123
So in this case, it makes sense that you have FK on the table produto
and create an index for her.
However, if it is more common to search for the standard packaging of a given product, it will be the following query that will repeat a lot:
select * from produto_embalagem where id_produto_padrao = 123
Hence in this second scenario you will prefer to have the FK on the table produto_embalagem
and have an index for her.
You should analyze your application and see which of the two situations is most common.
But what would be the most "academic" way? Is there some kind of best practices for this situation?
– Ricardo Melo
@Ricardomelo I added two examples to make it clearer.
– Gabriel
Thank you very much!
– Ricardo Melo