This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I want to import data from another database using JDBC. All the tables have sequence as the primary key and the sequences on the source and destination need not match. I want to enter data into 'N' related tables (having the sequence column as the foreign key) in a single transaction. What is the best approach to achieve this?
Thanks in advance
Joined: Jul 27, 2009
Well, let me make my question more clear.
I have a Java application (job) which receives data for multiple tables from another schema. These tables have DB sequence as the primary key. Now I want to replicate the data from this schema onto my schema using a Java program. How can i handle sequences and Foreign key references to these sequences while executing the java job?
in which format your job receives the input data? is it Flat file or delimited file or Excel or some other?
whatever it may be, in the output schema why do you bother about the sequence of the input schema.
Just consider that as input field and persist in your resultant DB schema. If you want you can make that column as PK.
If you have FK columns, first in the referred table then referring table.
Joined: Jul 27, 2009
Thanks Krish for the response...
I get the input as a flat file.
Say, I have 3 related tables... Student -> Student_Address -> Location. Each of these tables have Sequence as primary key.
I have to import data for all the 3 tables in the same transaction. Is it possible?
Joined: May 18, 2007
I assume Student and Location are independent tables. And Student_Address is dependent on both these tables.
Also from your mail I understand you will get Student_id (PK of student table), Location_id (PK of Location table).
So, you first insert these two tables and then insert the Student_Address table.