Jump to content

Recommended Posts

Okay, so I messed up big time.

 

I have a database made up of these tables:

Animals - ID, Name, Photo

Themes - ID, Theme, Comment

AnimalsThemes - ID, Name, Theme

 

I had the AnimalsMethods and AnimalsThemes relate Animals.Name to AnimalsThemes.Name and Themes.Theme to AnimalsThemes.Theme

 

Now I realize I should have been relating the IDs.

 

Is there any way I can do this, now that my tables have way too much information to start over?

 

I'm thinking that I should be importing the IDs relating to the names so that I can then delete the names column. Problem is, I don't know how to import the proper IDs to coincide with the proper names.

 

Here's hoping for a solution!

 

 

Link to comment
https://forums.phpfreaks.com/topic/220695-redefine-relational-tables/
Share on other sites

Well, then it should be pretty straightforward -- assuming each name has only a single ID, and vice versa.

 

Add new columns called animal_id, theme_id, etc. to the appropriate tables -- these will ultimately replace the name lookups.

 

Then simply issue an update to each table, and use a subquery to pull back the ID for each given name.

 

Then you can drop the other columns -- once you've updated your application code, foreign keys, etc.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.