Chapter 2: Many-to-Many Relationship

The lecture about the Many-to-Many Relationship between Items and Stores discussed two approaches to creating references between items and stores:

  1. an array of storeIds in each item
  2. an array of item_ids in each store

Not discussed was the creation of a join table, named item_store, which would contain only the storeId and item_id fields.

Why?

Those of us coming from a relational SQL background (who came of age trying to squeeze our data into E. F. Codd’s first, second and third normal forms) would reflexively reach for the join table solution.

Are join tables to be avoided in document database systems?

What disadvantage would the join table approach entail that would preclude it’s discussion in the lecture?

Hi @gnumskull,

The concept of a join/bridge/junction/linking/intermediate/intersection table doesn’t exist in this world. That’s why you embed or reference an array of sub-documents. The array of sub-documents acts as your bridge. In addition, there’s no concept of foreign key constraints thereby reinforcing the absence of the join table concept.

2 Likes

Thank you for the explanation. It is helpful.

:slightly_smiling_face: :+1: