1
It is possible to create a composite primary key using a foreign key?
I have the table mov_estoque
, where I thought to put as composite key the id_mov
and id_prod
, however, id_prod
is a foreign key of the products table.
tried:
ALTER TABLE mov_estoque
DROP PRIMARY KEY, ADD PRIMARY KEY (id,id_pro);
but I get:
1832 - Cannot change column 'id_pro': used in a Foreign key Constraint 'mov_estoque_ibfk_2'
Why does it have to be composed? Perhaps a drive table and an auxiliary relating n to n drive-products would be more cohesive in the model, so vc would have separate drive and products of this drive
– jefissu