Extended Reference Pattern

noun

say it: “ik-STEN-did REF-er-uns PAT-ern” /ɪkˈstɛndɪd ˈrɛfərəns ˈpætərn/

A data design where a record keeps another record's id plus a copy of the few details it shows most often.

What is the extended reference pattern?

The extended reference pattern keeps another document's _id plus a copy of the few fields a page shows with it, such as a product's name and the price paid in an order. The page reads one document, and the copied fields are ones that rarely change.

db.orders.insertOne({
  customerId: 31,
  items: [{ productId: 7, name: "Trail Helmet", pricePaid: NumberDecimal("59.99") }]
});

In a sentence

  • “With the extended reference pattern, the order page shows each product's name without looking up the product.”
  • “The price paid belongs in the extended reference pattern's copy, because it must not change when the product's price does.”

Level: Journeyman · More MongoDB terms at this level

Updated