[TYPO3-mvc] mmm-relationship

Franz Koch typo3.RemoveForMessage at elements-net.de
Mon Jun 7 14:53:41 CEST 2010


Hey,

> I am having a hard time thinking of a proper way to implement a
> three-way relationship (mmm-relationship?). Here's the concrete case: in
> my data model I have a relationship between a company, product and role.
> For example: a company can be a producer and the distributor of a
> certain product (producer and distributor are roles). I would need to
> make something like a table company_product_role_mmm, but this exists
> only for the relationship between two entities, not three. Do you have
> any idea how to implement this?

I'd actually skip the "producer" role and assign it directly to the product:

Tx_YourExt_Domain_Model_Product {
	/**
	 * @var Tx_YourExt_Domain_Model_Company
	 */
	protected $producer
}


If that doesn't fit your domain, use a intermediate object to store the 
needed information there:

Product -> WhatEverNameFitsInHere <- Company

Tx_YourExt_Domain_Model_WhatEverNameFitsInHere {
	protected $product;
	protected $company;
	protected $role;
}


"WhatEverNameFitsInHere" should of course get replaced by a name that 
suits your domain :)

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list