Using Doctrine 2 and Symfony here. I'm fairly new to Doctrine and can't find what I'm looking for in their docs, so I'm looking for some guidance on a situation.
I have these entities: 1. Profile (profile of a person, a person can have many addresses) 2. School (school info, a school can have many addresses) 3. Address (all addresses, associated to one of the above entities)
Previously, I had Profile, ProfileAddress, School, SchoolAddress, which worked fine, but I'd rather have a single class/table to make address updates to because I may get other entities down the road which also need addresses. Also, if my address format changes, I just want to change ONE class/table instead of many.
My question is this... Is it possible to associated two (or more) different entities to a single entity? Here is an example of the data I would EXPECT to see in the actual tables.
-Profiles-
|id|fname |lname|
| 1|John |Smith|
| 2|Jane |Jones|
-Schools-
|id|name |type |
| 1|City College |University |
| 2|Greendale |Community College|
-Addresses-
|id|src_id|src |type |address1 |address2|
| 1| 1|profiles|maling |PO BOX 555 | |
| 2| 1|profiles|physical|123 W. Main St. |Apt A |
| 3| 1|schools |physical|541 University Way| |
| 4| 2|schools |physical|111 Winger Ave | |
Is this possible with Doctrine? If so HOW? Or is there a better way I could design this? What have others done in this situation?