Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Coder's Corner Lounge (http://www.programmingforums.org/forum11.html)
-   -   Linking Database Tables (http://www.programmingforums.org/showthread.php?t=15001)

ReggaetonKing Jan 22nd, 2008 2:49 PM

Linking Database Tables
 
I am trying to migrate some data from one database to another. The new database's tables have different column names than the old tables.

Is there some tool I can use to link the two tables together that will write queries to export the data and import into the new tables? Because we're taking an average of 70 columns in each table and it's taking a long time to write the queries myself.

Thanks.

EDIT: Please ask any questions you have. I know my explanation is not very clear. :)

Sane Jan 22nd, 2008 4:36 PM

Re: Linking Database Tables
 
It might be important to know how the column names are changing.

Is it completely arbitrary? Or are they all changing by a common prefix?

For example, do the changes look like so...?

:

nickname -> user_nickname
birthday -> user_birthday


Or... like so?

:

nickname -> username
birthday -> dmy_birth


And is this consistent throughout all tables in the database? Does the prefix rule differ? Or is it completely arbitrary for each and every table?

ReggaetonKing Jan 22nd, 2008 5:45 PM

Re: Linking Database Tables
 
Quote:

Originally Posted by Sane (Post 140080)
It might be important to know how the column names are changing.

Is it completely arbitrary? Or are they all changing by a common prefix?

For example, do the changes look like so...?

:

nickname -> user_nickname
birthday -> user_birthday

Or... like so?

:

nickname -> username
birthday -> dmy_birth

And is this consistent throughout all tables in the database? Does the prefix rule differ? Or is it completely arbitrary for each and every table?

There is no consistency when the columns were renamed (wasn't up to me...) nor is there a prefix on any of the column names.

Here are some examples of the column names:
:

HrsSinceOvrHl -> HoursSinceOverHaul
TGateA -> TimingGateA
TGB -> TimingGateB
BR_1 -> Bearing1

This project couldn't be more stressful!

Sane Jan 22nd, 2008 5:51 PM

Re: Linking Database Tables
 
Quote:

Originally Posted by ReggaetonKing (Post 140095)
There is no consistency when the columns were renamed (wasn't up to me...) nor is there a prefix on any of the column names.

Here are some examples of the column names:
:

HrsSinceOvrHl -> HoursSinceOverHaul
TGateA -> TimingGateA
TGB -> TimingGateB
BR_1 -> Bearing1

This project couldn't be more stressful!


I feel for you.

It seems like nothing could be faster than whipping up a single php script, to alter every tables' columns, with some SQL queries.

http://dev.mysql.com/doc/refman/5.0/en/alter-table.html

I don't see how there could be possibly anything faster than that, because either way... you're going to have to type out the name of every column, right? Unless the name of each column already exists on the other database, in which case you could write another script to extract all of the column names, for each table, into some arrays. Then paste those array declarations into the previously mentioned script, handle the arrays properly, effectively speeding up the process of writing out each column name yourself.

In other words, even if a tool did exist, I don't see how it could outdue the power and speed of writing some innovative queries yourself.

ReggaetonKing Jan 23rd, 2008 8:56 AM

Re: Linking Database Tables
 
Thanks for your help Sane. Greatly appreciated.


All times are GMT -5. The time now is 3:41 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC