List:General Discussion« Previous MessageNext Message »
From:Michael T. Babcock Date:November 8 2002 4:21pm
Subject:Re: how do you define a relationship?
View as plain text  
Hammons Randy G SSgt 612 ACOMS/SCXX wrote:

>Unfortunately this goes well beyond the scope of my original question.
>Although the inputs that you all have provided thus far have been a very
>good read, I still don't grasp the concept of defining a relationship.  Is
>it simply referring to a primary key in a field other than the one where the
>key was defined?  Or is there some other way to define a key that I don't
>see?  All I'm looking for is a simple example, syntax excerpt, etc...that
>shows me (only the "slow learner" level) exactly how to define a
>relationship.
>  
>

In InnoDB tables, there is a syntax for defining "foreign keys" (look it 
up on mysql.com/doc), otherwise the JOIN examples you've been given is 
_how_.  The definition isn't explicit (unless using foreign keys), its 
implicit in the use of the JOIN.

SELECT * FROM a
    LEFT JOIN b ON b.primary_key = a.foreign_key_b
    LEFT JOIN c ON c.primary_key = b.foreign_key_c

... the foreign_key_x values are simply values that match those 
available from the primary_keys they reference (hopefully all indexed).

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


Thread
how do you define a relationship?Randy Hammons20 Oct
  • Re: how do you define a relationship?Richard Clarke20 Oct
  • RE: how do you define a relationship?bwarehouse21 Oct
    • RE: how do you define a relationship?Arthur Fuller21 Oct
      • Re: how do you define a relationship?Michael T. Babcock21 Oct
RE: how do you define a relationship?Jan Steinman21 Oct
Re: how do you define a relationship?Michael T. Babcock21 Oct
RE: how do you define a relationship?Hammons Randy G SSgt 612 ACOMS/SCXX22 Oct
  • Re: how do you define a relationship?Peter Brawley22 Oct
  • RE: how do you define a relationship?Arthur Fuller23 Oct
    • re: RE: how do you define a relationship?Egor Egorov24 Oct
  • Re: how do you define a relationship?Michael T. Babcock8 Nov