• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Using Self-Joins

A special type of relationship always requires an alias: a self-join. This is a relationship from a table to itself. The PartiesAndGuests table simply lists pairs of data values—parties and guests. Relationships link Party ID to the Parties table and Guest ID to the Guests table. With a self-join, you can link them to an alias of the table. This allows you to display all the parties to which a specific guest is invited as well as all the guests invited to a given party.

Self-joins also are useful in implementing edits. For example, a purchase order might consist of a variety of items that are ordered; some might be mutually exclusive. (If you order A, you cannot order B.) Using a self-join, you can find all the records that contain both A and B: If there are any, the edit fails.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint