QamoosTech
DatabasesData modelingIntermediateSQLDjango

Join Table

PronunciationJOYN TAY-bul

Definition

A join table is a table whose rows connect rows from two other tables, usually with two foreign keys. It is how a many-to-many relationship is stored.

Where you hear it

In schema design, ORM documentation for many-to-many fields, and database interviews.

Examples

  • The enrollment table is a join table between students and courses.
  • Django creates the join table for a many-to-many field automatically.
  • The course_students join table holds one row for each student enrolled in a course.

Common mistake

Not adding a unique constraint on the pair of keys. The same link can then be stored twice.

Don't confuse with

A SQL JOIN, which is a query that combines tables. A join table is a real table that stores the links.

Say it at work

  • In a meeting or chatAdd a join table with the two foreign keys and a unique pair.
  • In an email or ticketThe join table can also hold extra data, like the date someone joined.