Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > Re: Getting tab...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 10 Topic 3695 of 3784
Post > Topic >>

Re: Getting tables in insertion order

by blueparty <partner50449476@[EMAIL PROTECTED] > Apr 4, 2008 at 07:39 AM

On Apr 2, 1:25 pm, Sankar <pr.san...@[EMAIL PROTECTED]
> wrote:
> Hi,
>   I am new to Database..I donot want insertion order of rows or
> records.. I need insertion order of tables..
>
> Consider if i am migrating from sourceDB to targetDB..through
> programatically
>
> First i will create DB and all tables in the targetDB..
>
> Then I have to move all the datas from sourceDB to targetDB... Here
> for moving i need insertion order of tables(to take care of forign key
> violations .. parent tables first thn child tables)
>

I was doing that a couple of times, it required a little bit of
programming.
I used to create additional table called dictionary. It contained
following columns:

create table dictionary (
source_id bigint,
target_id bigint,
data_class varchar(16)
);

I "walked" through the source tables (the order in which tables are
browsed is im****tant because of
foreign keys). For each record I put ID into source_id, and add
data_class which is the identifier of the data type,
it could be the name of the source table. 'target_id' contained an ID
of the row in the target table.
When I encountered a column that had a foreign key constrain, I looked
at the dictionary to find the target
ID that corresponds to the ID found in source table.

For example there were students which were organized in groups.  So I
processed 'group' table first, and student data
after it. The dictionary looked like this:

SOURCE_ID      TARGET_ID        DATA_CLASS
1              25               'group'
2              99               'group'
5              78               'student'
11             44               'student'

So, if student ID=5 belonged to the group ID=2 in old database, I
inserted the same student, with group_ID=99, which is
the corresponding ID in the new database. The student was assigned the
ID=78 by the database engine, which is recorded in the dictionary,
too.

I used to do it in Groovy, now I would do that in Beanshell.
It pays off to have a im****t script if you are doing the transfer from
the old application.
It is often the case that client does not have data in 100% perfect
shape, which becomes obvious during transition,
so you might be asked to convert data more than once.

B
 




 10 Posts in Topic:
Getting tables in insertion order
Sankar <pr.sankar@[EMA  2008-04-01 00:45:28 
Re: Getting tables in insertion order
Lew <lew@[EMAIL PROTEC  2008-04-01 07:33:38 
Re: Getting tables in insertion order
Sabine Dinis Blochberger   2008-04-01 12:54:21 
Re: Getting tables in insertion order
Dyreatnews@[EMAIL PROTECT  2008-04-01 14:16:04 
Re: Getting tables in insertion order
Roedy Green <see_websi  2008-04-01 13:44:50 
Re: Getting tables in insertion order
Roedy Green <see_websi  2008-04-01 21:08:26 
Re: Getting tables in insertion order
Sankar <pr.sankar@[EMA  2008-04-02 04:25:01 
Re: Getting tables in insertion order
Silvio Bierman <sbierm  2008-04-02 13:45:34 
Re: Getting tables in insertion order
Roedy Green <see_websi  2008-04-03 08:45:20 
Re: Getting tables in insertion order
blueparty <partner5044  2008-04-04 07:39:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 6:43:06 CDT 2008.