Foreign keys referencing values inserted in the same project
tilo23
Posts: 27
I am not sure of how the foreign key generator behaves if it references column also being generated in the same project. i.e.
Assume the Project generates data for Table_1 and Table_2.
Column_A from table Table_1 has a foreign key referencing Column_B in Table_2.
If I run the project, will the Column_A be populated with values being inserted into Column_B, or will it pass to Column_A values existing in Column_B before insertion?
Is there any difference for this case between native foreign key and manually set foreign key generator?
Assume the Project generates data for Table_1 and Table_2.
Column_A from table Table_1 has a foreign key referencing Column_B in Table_2.
If I run the project, will the Column_A be populated with values being inserted into Column_B, or will it pass to Column_A values existing in Column_B before insertion?
Is there any difference for this case between native foreign key and manually set foreign key generator?
Inside the Dilbert's world
Comments
From what I can tell, SQL Data Generator selects values from the primary key column of the source table to use as data in the column in the other side of the foreign key relationship. This seems to be independent of the PK value generation, otherwise you could not remove the source table containing the PK column from the project.
There is a good description of how the FK generator works here: http://www.red-gate.com/supportcenter/c ... generators
In situations where you don't have an FK constraint in the database or where the FK is a simple 1:1 relationship, you can switch to the foreign key (manual) generator. Otherwise you have no choice but to use the automatic FK generator.