Many-to-Many Bidirectional Relationship
Learn how to change the unidirectional many-to-many relationship to a bidirectional relationship.
We'll cover the following
In a bidirectional relationship, each side has a reference to the other. In our example, the Category
class did not have any reference to the Tournament
class. Now we will add a reference to the Tournament
class so that the relationship can be navigated from both sides. This will have no effect on the underlying database structure. The join table tournament_catogories already has the foreign keys of both the tournament and category tables, and it is possible to write SQL queries to get tournaments associated with a category.
Get hands-on with 1400+ tech skills courses.