| Author |
Message |
tilo23
Joined: 22 Dec 2011 Posts: 19 Location: Berkshire, UK
|
Posted: Thu Feb 16, 2012 1:21 pm Post subject: Foreign keys referencing values inserted in the same project |
|
|
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 |
|
| Back to top |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6344 Location: Red Gate Software
|
Posted: Fri Feb 17, 2012 4:46 pm Post subject: |
|
|
Hello,
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/content/SQL_Data_Generator/help/2.0/SDG_About_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. _________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
tilo23
Joined: 22 Dec 2011 Posts: 19 Location: Berkshire, UK
|
Posted: Mon Feb 20, 2012 1:29 pm Post subject: |
|
|
Thanks for the clarification. _________________ Inside the Dilbert's world |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group