I have a movie database I am working on and before I start working on the php side I want to make sure the database is solid.
As I have mass imported data scraped from the web currently my results in the columns for genre and actors are in text strings. I want to convert them to unique ids and create relationship tables.
Essentially how it is now:
Movie Table
Movie ID - Movie name - Genres - Actors 1 - Inception - Sci Fi - Leonardo Di Caprio, Ellen Page
How I want it:
Movie Table
Movie ID - Movie Name 1 - Inception
Genre Table
Genre ID - Genre Name 1 - Sci Fi
Actor Table
Actor ID - Actor Name 1 - Leonardo Di Caprio 2 - Ellen Page
Genre Relationships Table
Movie ID - Genre ID 1 - 1
Actor Relationships Table
Movie ID - Actor ID 1 - 1 1 - 2
If it was just the genres then I could do this by hand but as there are thousands of movies and actors I am struggling to come up with a simple approach to convert all this data.
I have a csv dump of all the data and figure it could be done by using a php script to import it in this format or I don't know if it's possible to run SQL commands to sort the data this way (the database has over 200,000 movies).
Any hints or ideas on how to accomplish this would be much appreciated!