MongoDB Tutorial 0/120 lessons ~6 min read Lesson 25
One-to-Many Relationships
One-to-many (1:N) is where modeling gets interesting.
Course progress0%
Focus
4 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
One-to-many (1:N) is where modeling gets interesting. The answer depends on N: a handful of comments? embed. Thousands of orders? reference. Bounded vs unbounded is the line.
Syntax reference
js
// 1:few — embed{ post: "...", comments: [ { author, text }, ... ] }// 1:many — reference// users: { _id, name }// orders: { _id, userId, total }
Real-world use
Blog posts embed their first 5 comments and reference older ones in a separate collection — a hybrid pattern called the extended reference.
Best practices
- Use the 'extended reference' pattern for huge 1:N where you want fast recent reads.
Ready to mark this lesson complete?Track your journey across the entire course.