I am am doing “MongoDB Python Developer Path”. In Lesson 4: Data Relationships of “MongoDB and the Document Model” unit, the instructor explains 1:1 relationship like this:
“One to one relationship exists when one entity is related to exactly one other entity.
For example, a movie is released by a single studio.
Therefore, the relationship between the studio and the movie is a one to one relationship”
I have small “existential” doubt. My first thought is:
Even if a movie can be released by a single studio, given studio may have released many movies. That’s why I see it as a 1:n relationship.
Is it a mistake, or I am biased by thinking about relations between entity types (collections/tables), rather than relations between concrete entities (documents/rows)?
In MongoDB, a 1:1 relationship means one document is linked to exactly one other document. Since MongoDB is document-based, you usually embed the related data inside the same document instead of using separate tables like in SQL.
Example: Suppose you have a User and a Profile where each user has exactly one profile.
You can embed the profile directly inside the user document: