ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

MongoDB NoSQL Database Tutorial• 6 min read

Schema Design: Embedding vs. Referencing

Learn when to embed sub-documents for 1-to-few data vs. when to reference across collections for 1-to-many relationships.

The Golden Rule of MongoDB Schema Design

Embed: When data is accessed together, has 1-to-few relationships, and does not grow unboundedly (e.g., shipping addresses on a user).
Reference: When data is accessed independently, grows without bound (e.g., millions of server log entries), or requires many-to-many mappings.
ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

What is the maximum allowed BSON document size for a single document in MongoDB?