473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Conversion of Location Codes with Foreign Keys

I have to do a data migration for a client. The following conversion
is required.

Task:
- MOVEMENT table with 7,000,000 records, each has a location code
- Location code has changed; I have a mapping table with the old
location code and the new code

Issues:
- The conversion should be done in the same table as I do not want to
move the 7,000,000 records from one table to another if not necessary
- The table has a foreign key to a LOCATION master; this means that I
might have to update LOCATION first; however, I cannot just convert
the codes in LOCATION as this would trigger foreign key violations in
the MOVEMENT table; I also cannot just add the new locations because
some new codes might be the same as existing old codes (e.g. the new
code 'PDP' for 'Purchasing Department' could be the same as the old
'PDP' for 'Public Relations Department'.

Does anybody know what the best approach would be here?

Michael
Jul 19 '05 #1
2 2425
mi***********@gmx.de (Michael) wrote in message news:<e9*************************@posting.google.c om>...
I have to do a data migration for a client. The following conversion
is required.

Task:
- MOVEMENT table with 7,000,000 records, each has a location code
- Location code has changed; I have a mapping table with the old
location code and the new code

Issues:
- The conversion should be done in the same table as I do not want to
move the 7,000,000 records from one table to another if not necessary
- The table has a foreign key to a LOCATION master; this means that I
might have to update LOCATION first; however, I cannot just convert
the codes in LOCATION as this would trigger foreign key violations in
the MOVEMENT table; I also cannot just add the new locations because
some new codes might be the same as existing old codes (e.g. the new
code 'PDP' for 'Purchasing Department' could be the same as the old
'PDP' for 'Public Relations Department'.

Does anybody know what the best approach would be here?

Michael


drop or disable the constraint,
truncate the LOCATION master,
load the LOCATION master,
convert the MOVEMENT table,
restore the FK constraint
(deal with any constraint violations)

It should not be hard to do.
ed
Jul 19 '05 #2
mi***********@gmx.de (Michael) wrote in message news:<e9*************************@posting.google.c om>...
I have to do a data migration for a client. The following conversion
is required.

Task:
- MOVEMENT table with 7,000,000 records, each has a location code
- Location code has changed; I have a mapping table with the old
location code and the new code

Issues:
- The conversion should be done in the same table as I do not want to
move the 7,000,000 records from one table to another if not necessary
- The table has a foreign key to a LOCATION master; this means that I
might have to update LOCATION first; however, I cannot just convert
the codes in LOCATION as this would trigger foreign key violations in
the MOVEMENT table; I also cannot just add the new locations because
some new codes might be the same as existing old codes (e.g. the new
code 'PDP' for 'Purchasing Department' could be the same as the old
'PDP' for 'Public Relations Department'.

Does anybody know what the best approach would be here?

Michael


Here are some thoughs. In theory there are 3 possibilites in the
relationship of the old and new codes:
1- the old code and the new code are the same - nothing has to be done
2- the old code points to a new code that does not currently exist
I would handle these first
3- the old code points to a new code but the new code is currently in
use
this will require first processing the data with the new code value

If you find an old code that points to a not currently existing new
code and migrate it to the new code then the old code now becomes
available for reuse and when you assign the data to this new value
then this old value now becomes available for reuse.

This bring up another point for item 3 the old code may be on the list
for reuse or it may not.

Using the information and logic above I would create a dependency
chain where A goes into B into C into D to Z and then start processing
at Z driving up through the chain in the reverse order. Each location
freed is then available to the prior location.

Now because every location may not be reused, what you may actually
have is a series of chains rather than one unbroken chain though by
choosing one of the new not currently used values and processing the
location that moves to it you can string the chains together to form
one complete processing order.

Rather than try to build the chain on the fly I would write some plsql
to build the chain and save it in a new column on the old to new
table. I would also consider adding columns to indicate that the
value has been processed for both building the chain and reassigning
the data.

HTH -- Mark D Powell --
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Olivier Crèvecoeur | last post by:
Hello, Excuse me for my poor english. I would kike know if create index on the foreign key it's necessary or if Oracle, are optimized for using foreign key whithout index. Best regards ...
10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
1
by: Vinodh Kumar P | last post by:
I understand the number of foreign keys allowed is restricted by the DBMS I use. In a general relational schema design perspective how many foreign keys a table shall have? If I have large number...
0
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A...
2
by: Ian Davies | last post by:
I have created a database with about 17 tables. I have been creating foreign keys some of which have worked but when creating others I get the message below ************************* 1005...
9
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for...
1
by: rbarber | last post by:
I have to synchronize 2 databases hourly but am having difficulty maintaining foreign key relations. These tables use auto-increment columns as primary keys, with child records in other tables...
1
by: apax999 | last post by:
Kinda new to SQL, using SQL Server 2005. I have some foreign keys in a couple of tables. I need to drop these tables, but can't since I'll get the error: Msg 3726, Level 16, State 1, Line...
1
by: Michael | last post by:
I have to do a data migration for a client. The following conversion is required. Task: - MOVEMENT table with 7,000,000 records, each has a location code - Location code has changed; I have a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.