The One-to-One Relationship
In this lesson, we will learn how to add a one-to-one relationship between models.
Introduction #
In the last lesson, we created a one-to-many relationship between the Employee and Department models. The code so far is given below:
Now, let’s learn how to add a one-to-one relationship between these models as well.
Representing a one-to-one relationship in models
In this example, a one-to-one relationship should exist between the Employee and Department. This relationship will indicate that an employee can be the head of a ...