views:

60

answers:

2

I have the following table - Actor, Actresses, Director & Movie.

First 2 tables have many to many relationship with movie table.

So i have created Celebrity_Movie table which has primary key of all these tables as foreign key.

So my question is how can I insert records in Celebrity_Movie table.

Because there can be multiple actors, actresses in a movie. e.g. Movie 'Race' has multiple actors & multiple actresses. So how to fill data in Celebrity_Movie table for 'Race' movie?

Actor table
Actor_id Actor_name
1        Amitabh
2        Akshay kumar
3        Hritik roshan
4        Amir khan
5        R. Madhavan
6        Sharman joshi
7        Ajay devgan
8        Tushar
9        Arshad varsi

Actress
Actress_id Actress_name
1          Aishwairya
2          Katrina
3          Bipasha
4          Sameera reddy
5          Kareena
6          Amrita rao

Director
Direct_id Direct_name
1         Abbas_Mustan
2         Priyadarshan

Movie
Movie_id Movie_name
M1       Race
M2       Golmal2
M3       3 Idiots
+1  A: 

You need three many-to-many relationship tables because you want to relate Director, Actor and Actress tables to Movies.

There are several ways to do this:

1) Probably best is to simply create the three different relationship tables:

Actors_Movies
  id
  actor_id # foreign key
  movie_id

Actresses_Movies
  id
  actress_id
  movie_id

Directors_Movies
  id
  director_id
  movie_id

Other ways are more complicated where a single join table is used for the different types of joins (Actor, Actress, Director). To start with, I recommend the three Join tables.

Added If you only want to many-to-many for the actor/actresses, the easiest way is to redefine a "Talent" table instead of the Actor/Actress tables to handle both:

Talent table
  id
  name
  actor   # boolean: true means an actor, false means an actress

Talent_Movie  # many to many
  id
  talent_id
  movie_id
Larry K
+1  A: 

As other previously has stated you need three many-to-many tables.

Might I suggest that you consider using only one person table and include the sex of the person. Furthermore you could add a 'role' to the relation table to indicate what role the person has (actor/director etc.) in a given movie.

mbanzon
The role is a good plan because ... well, Clint Eastwood, for example, has starred and directed in his own movies a few times now...
JUST MY correct OPINION