Data Modeling
One-to-One Relationships
When a nested object is enough, and when a second collection is cleaner.
One-to-one is almost always a nested object on the same document. Rahul's address is not a collection. You query "address.city". You update it in the same updateOne as city.
{
_id: ObjectId("64a1b2c3d4e5f6a7b8c90001"),
name: "Rahul",
city: "Bangalore",
address: { line1: "Indiranagar", city: "Bangalore", pin: "560001" }
}Split into a second collection when the extra object is large and rarely read (a KYC blob, a 2MB settings dump), has a different security boundary, or a different team / service owns it. Then userId on profiles and two reads — or one $lookup on the admin path only. Do not split because SQL had user_profiles.
Interview question
How do you model a one-to-one relationship in MongoDB?
Embed it as a nested object on the same document — address on the user. Split collections only if the extra data is large and rarely read, has different access control, or a different lifecycle. A second collection for every 1:1 is copying SQL without the access pattern.