Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 22nd, 2008, 1:49 PM   #1
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
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.
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old Jan 22nd, 2008, 3:36 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,838
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
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?
Sane is offline   Reply With Quote
Old Jan 22nd, 2008, 4:45 PM   #3
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Re: Linking Database Tables

Quote:
Originally Posted by Sane View Post
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!
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old Jan 22nd, 2008, 4:51 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,838
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Linking Database Tables

Quote:
Originally Posted by ReggaetonKing View Post
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.
Sane is offline   Reply With Quote
Old Jan 23rd, 2008, 7:56 AM   #5
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Re: Linking Database Tables

Thanks for your help Sane. Greatly appreciated.
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing BLOBs in a database - problem jonyzz Other Programming Languages 8 Jan 31st, 2007 4:38 AM
Linking 2 tables gj15987 Delphi 1 Nov 4th, 2005 7:42 AM
java and MS Access database borceivanovski Java 0 Apr 26th, 2005 4:28 PM
Using ODBC to connect to a remote database in a C program bigi C++ 1 Mar 8th, 2005 3:19 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:23 PM.

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