MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Michael T. Babcock Date:October 16 2002 4:20pm
Subject:Re: Normalization sql
View as plain text  
John Chang wrote:

>
>> Studios (StudioName, StudioID)
>> Genres (GenreName, GenreID)
>> Titles (VideoTitle, Details, StudioID, GenreID, BitRateID, TitleID)
>> Actors (F_Name, L_Name, ActorID)
>> Stars (TitleID, ActorID)
>
> TitleGenres (TitleID, GenreID)
>
> So, if I just use theses tables I will be OK if the video has multiple 
> titles, multiple actors, & multiple genres?
>
> How do I create a junction table?  Example, between Genres and Titles, 
> how do I add the to PK fields to TitleGenres?  Do I just create the 
> TitleGenres table and add the TitleID & GenreID field and does the 
> database know they are linked?

Sort of; assuming you create a junction table called "TitleActors" with 
TitleID, ActorID, and you want the movies with "Stalone" as the actor 
them, you might do a query like:

select * from Titles
    LEFT JOIN TitleActors ON Title.ID = TitleID
    LEFT JOIN Actors ON ActorID = Actors.ID
    WHERE Actors.L_Name = "Stalone";

-- 
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock


Thread
Normalization sqlJohn Chang14 Oct
  • Re: Normalization sqlArthur Fuller14 Oct
    • Re: Normalization sqlJohn Chang15 Oct
  • Re: Normalization sqlMichael Zimmermann14 Oct
    • Re: Normalization sqlJohn Chang14 Oct
  • Re: Normalization sqlMichael T. Babcock16 Oct
    • Re: Normalization sqlJohn Chang20 Oct
  • Re: Normalization sqlArthur Fuller17 Oct
  • Re: Normalization sqlMichael T. Babcock21 Oct