MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
One-to-Few (Embedded) vs One-to-Many (Referenced) Data Modeling0%
Study Materials
MongoDB & MongooseProgress 0%
1.1Document Databases vs Relational SQL: CAP Theorem & When to Use NoSQL1.2JSON vs BSON Data Types & MongoDB Internal Storage Engine (WiredTiger)1.3MongoDB Atlas Cloud Setup, Network Whitelisting & Compass GUI
4.1One-to-Few (Embedded) vs One-to-Many (Referenced) Data Modeling4.2Query Population with .populate() & Multi-Level Population4.3Aggregation Pipeline Architecture: $match, $group, $project & $sort4.4Multi-Table Joins with $lookup & Array Flattening with $unwind4.5Database Indexing Strategies (Single, Compound, TTL) & Query Optimization
HomeTutorialsMongoDB & MongooseOne-to-Few (Embedded) vs One-to-Many (Referenced) Data Modeling
Query Population with .populate() & Multi-Level Population

One-to-Few (Embedded) vs One-to-Many (Referenced) Data Modeling

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

In relational databases, normalization dictates splitting entities across multiple tables linked by foreign keys. In MongoDB, data modeling is governed by the golden rule: "Data that is accessed together should be stored together." Choosing between Embedding (Denormalization) and Referencing (Normalization) is the most crucial architectural decision in NoSQL system design.


1. The Three Cardinal Rules of MongoDB Data Modeling

  1. 1
    Rule 1: Favor embedding unless there is a compelling reason not to.
  2. 2
    Rule 2: Needing to access an object on its own is a compelling reason not to embed it.
  3. 3
    Rule 3: Avoid arrays that grow without bound (the 16 MB document size limit).

2. Approach 1: Embedding (Denormalization / Subdocuments)

When related data has a One-to-Few or One-to-Squillions relationship that is always retrieved together:

1// User document with embedded addresses
2const userSchema = new Schema({
3 name: String,
4 email: String,
5 addresses: [
6 {
7 street: String,
8 city: String,
9 postalCode: String,
10 isDefault: Boolean
11 }
12 ]
13});

When to Embed:

  • One-to-Few: A user has 2 or 3 shipping addresses; an article has 3 tags.
  • Atomic Updates: Updating a parent and its subdocuments in a single atomic write operation without transactions.
  • Read Performance: Fetching the parent retrieves all data in a single disk read without joins.

3. Approach 2: Referencing (Normalization / Document Links)

When data has a One-to-Many (Unbounded) or Many-to-Many relationship, or when child entities must be queried independently:

1// Post Schema referencing author
2const postSchema = new Schema({
3 title: String,
4 content: String,
5 author: {
6 type: Schema.Types.ObjectId,
7 ref: 'User', // Reference to the User model
8 required: true
9 }
10});
11 
12// User Schema (keeps user document lean)
13const userSchema = new Schema({
14 name: String,
15 email: String
16});

When to Reference:

  • One-to-Squillions: A YouTube channel with 10,000,000 log events or comments. Embedding an unbounded array would quickly breach MongoDB's 16 MB maximum document size limit!
  • Independent Queries: When child documents must be searched, filtered, and paginated on their own.
  • Frequently Changing Data: Storing mutable shared entities in one place prevents having to update thousands of duplicate embedded copies.

Interactive Quiz• Knowledge Check

Multiple Choice Questions

Question 1
What is the hard maximum BSON document size limit enforced by MongoDB?
Question 2
Why is embedding an unbounded array (such as all historical server logs or all user comments) directly inside a parent document considered an anti-pattern?
Question 3
What is the general rule of thumb for data modeling in MongoDB?
Question 4
When modeling a Many-to-Many relationship between Students and Courses, which pattern is most appropriate?
Question 5
In which scenario is Document Embedding strictly superior to Document Referencing?

Next Lesson

Query Population with .populate() & Multi-Level Population

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Virtual Properties, Instance Methods & Static Model MethodsQuery Population with .populate() & Multi-Level Population

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master MongoDB & Mongoose with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext