Tag Archives: Doctrine

Doctrine 2 ORM – Understanding of relationship/references between entities

Understanding of Reference and specially which site is owning and which is inverse in entities, could be tricky to understand for some people. Doctrine ORM provide easy way without having too much knowledge of database relationships.

References between objects are foreign keys in the database. You never have to work with the foreign keys directly, only with objects that represent the foreign key through their own identity.

For every foreign key you either have a Doctrine ManyToOne or OneToOne association. On the inverse sides of these foreign keys you can have OneToMany associations. Obviously you can have ManyToMany associations that connect two tables with each other through a join table with two foreign keys.

Continue reading