maintain key values

jputnamjputnam Posts: 4
edited August 18, 2016 5:32AM in SQL Data Generator
So i have multiple tables that have foreign keys. Let's say for example, there's an ID field and 2 tables with a 1:N relationship on that ID. I need to take that data in and replace the IDs, but i need to make sure that the records in the two tables still maintain that relationship. So if it replaces 123 with 456 (randomly) i need to be sure that it will ALWAYS replace 123 with 456. That needs to operate within the tables too; for instance, on the N side of the relationship i might have 20 records all with ID 123. All of them need to be 456 at the end.

Comments

  • Sounds complicated from your description.

    Not sure if this helps but there is a "Foreign key (manual)" generator that should reference values from another table at generation but I don't think it will do the cross-matching you're after for your multiple tables.

    It sounds a bit like you're pulling in some data from existing database values is that correct? (The masking ability of SQL Data Generator is something we're investigating currently)

    Are the id's being regenerated for the source table or is it an entirely newly generated table?

    For truly complex scenarios like this there is the python generator which could be used in a two-stage re-generation by first generating the source table and then storing a lookup for the second generation in a separate file.

    Hopefully this will give you areas to investigate.
    Richard Mitchell
    Project Manager
    Red Gate Software Ltd
Sign In or Register to comment.