Red Gate forums :: View topic - Foreign keys referencing values inserted in the same project
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Data Generator 2
SQL Data Generator 2 forum

Foreign keys referencing values inserted in the same project

Search in SQL Data Generator 2 forum
Post new topic   Reply to topic
Jump to:  
Author Message
tilo23



Joined: 22 Dec 2011
Posts: 19
Location: Berkshire, UK

PostPosted: Thu Feb 16, 2012 1:21 pm    Post subject: Foreign keys referencing values inserted in the same project Reply with quote

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
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6581

PostPosted: Fri Feb 17, 2012 4:46 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
tilo23



Joined: 22 Dec 2011
Posts: 19
Location: Berkshire, UK

PostPosted: Mon Feb 20, 2012 1:29 pm    Post subject: Reply with quote

Thanks for the clarification.
_________________
Inside the Dilbert's world
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic 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