Q:

MySQL Database Design Suggestion

I want suggestions for DB Design in MySQL.
I have a table Movie_Celebrity_Role which contains movie id, celeb id, role id.
This Table is the link between movies, celebs (CelebName & CelebID) and roles (eg: Producer, Director etc and resp ids) tables.
I have another table Movie_Company_Role which is similar as above But here instead of Celebs, Companies IDs are stored linked to Companies Table and Roles are different such as Production House etc.
My problem is there are some fields like Media Relations which may have both Company and Celebs.
Hence, If i create another table as MoviedID_CelebID_CompID_RoleID When joining the tables i will get duplicate error as celebs table and Companies table have to be joined on matching this table and also Movie_celeb_role and Movie_comp_role.
Please suggest on how to go about this.
I want the Result on my site to be like this:
Producer
    Celeb1
    Celeb2
Director
    Celeb1
    Celeb3
...
...
...
Media Relations
    Celeb2
    Company1
    Company12
PS: Also when i click a celeb or company link on this page it must go to celeb page or company page where the movies the celebrity or company associated must be listed with the role.

A:

very confusing...
what 'duplicate error' will you get?  so long as the role_id is valued properly from the role table, you should be ok.
Where you are not ok is that you have an ambiguity in your role definition.  In your example, you want to have 2 role_id values in your table, one for the company, and one for the person.
I'm not sure you would event want to do this anyhow... i would expect that a company may perform more than one role in a movie, and a person may as well. (e.g. someone may be the director, and an actor at the same time)
here you want this to be a separate table, not all jammed into one.

