G'day,

I have 2 databases with the same schema and I want to merge them into
one, maintaining relationships and not clobbering keys.

Here's roughly what I'm doing in perl/pseudocode:

@queue = ($some_random_object)
while ($object = shift @queue) {
  next if already_done($object);
  if (@many_to_ones = get_many_to_one_related_objects($object)) {
    unshift @queue, @many_to_ones;
    push @queue, $object;
    next;
  }
  clone_and_save_in_other_db($object);
  push @queue, get_one_to_many_related_objects($object);
}

So I basically grab all the many-to-one relations for an object, and
queue them up, along with all their many-to-one relations. After
there's no more "unmet dependencies" I then clone and save the object
into the other db (this method looks up the new keys for each object
from a hash that stores old/new keys, and sets the foreign keys for an
object accordingly). I then push the one-to-many related objects onto
the queue to process them....

I found that I also needed to put the if statement above within
another conditional which checks to see whether the traversal is
"going up" (already following a one-to-many path) and then if so,
avoids coming back down (following subsequent many-to-one
relationships) until the top is reached (there are no more
many-to-ones).

I'm sure I'm doing it wrong and that there is a simpler way,
especially from what I've seen in the Helper class -- it's just that
I'm not sure which part of the swiss-army-knife that is RDBO I should
use :)

Any hints and help on merging/migrating two databases into the one
with RDBO, whilst maintaining key relationships would be greatly
appreciated.

Stew

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to