ioeth Posted January 18, 2010 Share Posted January 18, 2010 I'm running into a situation that I can't seem to find any documentation about that I could use some help with. I'm trying to take input from a single table and map it to two tables, one of which has a foreign key to the other. My input would be something like:"customers" table code (varchar, pk) name (varchar, not null) address (varchar, not null) city (varchar, not null) state (varchar, not null) zip (varchar, not null)And my output would be something like:"people" table id (int, auto inc, pk) fk_addresses (int, not null, fk to addresses table) code (varchar, not null) name (varchar, not null)"addresses" table id (int, auto inc, pk) address (varchar, not null) city (varchar, not null) state (varchar, not null) zip (varchar, not null)So given the above input and output, I would need to map the "customers" table data into both the "people" and "addresses" table. Since the "people" table has a non-nullable foreign key to "addresses", I need to create the record in "addresses" first. After that, I need to create the "people" record with "addresses.id" in the "fk_addresses" column. Addresses should not be considered unique, so there's no way to do a lookup with the "customers" table. How would you approach a solution to this problem? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now