Skip to main content

What is data referencing in MongoDB?

Junior MongoDB
Quick Answer Data referencing stores the _id of a related document instead of embedding the data. Like a foreign key in SQL. Used when: data is large, shared across many documents, or independently accessed. Requires a separate query or $lookup to fetch the referenced data. Trade-off: two queries or slower $lookup vs embedded doc simplicity.

Answer

Referencing links documents across collections using IDs. It is used when datasets are large, loosely connected, or when avoiding duplication.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice