4
I have a system already in production of which the client requested a modification.
The modification is the creation of an EMPLOYEES table that will relate to the MOVEMENT table, creating a 1:N relationship (One Employee, several MOVEMENTS).
I know how to do the relationship when the table is empty. But in this case, as it is an EVOLUTIVE, the MOVEMENT table already has records. In theory, when creating the foreign key, this field could be null for the old data. However, giving the UPDATE-DATABASE, SQL returns the error the following error:
The ALTER TABLE statement conflicted with the FOREIGN KEY Constraint "Fk_dbo.Tb_mover_dbo.Tb_funcio_id_funcionario". The Conflict occurred in database "Fieldservice_desenv", table "dbo.TB_FUNCIONARIO", column 'Id'.
How do you outline this problem? What do you do in this case?
This is not the answer, and just a kick: maybe you have to "turn off" the key and "turn on" after changing, I’m not sure.
– Guilherme Nascimento
I’m not sure I understand your problem because I think Foreign Key might have nulls. First creates the column in the Drive table and then creates the FOREIGN KEY.
– ramaral