I'm working on a project in which I have an entity, we may call Users
and another entity Address
.
I want to define the entity User
in a way that an user would have a collection of addresses (typically a One-To-Many relationship), but I also need an attribute of user, let it be main_address
that would target a single value of the previous collection.
I would like to know if there is a conventional of doing this. The only solution I have now is to create another One-to-One relationship between Users . main_address
and Address
but this does not insure that the main_address
will actually be part of the User . addresses
collection.
I don't know if it could be important, because it's a rather theoretical question, but I'm using Doctrine 2.