Relationships

One-to-one

  • For each row in table A, there is exactly one corresponding row in table B; and vice versa
  • Tables in a one-to-one relationship should always have the same primary key, which will serve as the join column.

One-to-many

  • For each row in table A, there are any number of corresponding rows in table B
  • For each row in table B, there is exactly one corresponding row in table A
  • Tables in a one-to-many relationship should have a primary key in the "one" table that matches a foreign key in the "many" table.

Many-to-many

  • For each row in table A, there are any number of corresponding rows in table B; and vice versa
  • Many-to-many relationships can't be directly modeled in relational database programs.
  • These types of relationships must be broken into multiple one-to-many relationships, by creating a third, linking table, that contains a row for each relationship between the two tables.  Each row in the third table contains two foreign keys, one for each table.