Can I look up descriptions or names of foreign key codes?

wpostmawpostma Posts: 22
edited February 9, 2016 11:22AM in SQL Data Generator
Suppose I want to generate a table called MUSICTYPES, with integer id and string name, and I want to have INSTRUMENTS table that has a FK to MUSICTYPES.id, and the NAME of the instrument might be GUITAR 1, if the foreign key points to MUSICTYPE.id=1, having name 'GUITAR'.

In other words, randomly inserting GUITAR when the INSTRUMENT is not a guitar because it's not linked to MUSICTYPE=1 (GUITAR) is NOT useful to me.

How do I handle this? The Foreign Key generator appears useless to me as it is only useful for populating the actual field named InternalMusicTypeId which has the integer foreign key.

Maybe I could run some UPDATES after the generation. But then I can't insert random stuff beside the lookup value.




Warren

Comments

  • Hello Warren,

    I ran this by some of my colleagues and as far as we know it's not this advanced; SQL Data Generator is not able to populate one row based on another in the sense you mentioned mentions nor if you have State and StateAbbreviation it won't match them up (so you end with MI for California instead of Michigan). Perhaps there is a way to update it using your own script, but we're not sure exactly how that script would be.
    Allen LeVan
    Red Gate Software
    US Product Support
Sign In or Register to comment.