Foreign keys referencing values inserted in the same project

tilo23tilo23 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?
Inside the Dilbert's world


  • Brian DonahueBrian Donahue Posts: 6,590 New member

    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: ... 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.
  • Thanks for the clarification.
    Inside the Dilbert's world
Sign In or Register to comment.