|< < 22 > >|

Foreign keys have a "direction", joins do not

Foreign key direction

  • A foreign key has a direction. One table references the other.
  • The referenced table has no declaration to indicate that the FK exists.

Joins are symmetric

  • In these examples, the joins connect FK and PK columns.
  • This is not a coincidence.
  • In practice, I don't think I have ever seen a join that didn't connect a FK to a PK.
  • The join is the same, regardless of which way the query "navigates".

What are the titles of albums by The Detroit Cobras? Who created My Aim is True?
project( select( join(Artist, Album), name == 'The Detroit Cobras') [title]) project( select( join(Artist, Album), title == My Aim is True') [name])
  • That navigation has to do with what is known in the query (e.g. "The Detroit Cobras"), and what you are trying to find (their albums).
  • Note that some queries don't have such a "starting point", e.g. list all artists and their albums.

|< < 22 > >|