[TYPO3-english] Correct use of tablenames field in mm tables

Guillermo R. Oramas J. oramas.g at gmail.com
Fri Jun 17 18:48:44 CEST 2011


Hi. Thank you for the explication.

Like an example I have these three tables: customers, suppliers and countries.

CUSTOMERS
------------------------------
|   uid  |  customer   |
------------------------------
|    1   |  customer1  |
------------------------------

SUPPLIERS
----------------------------
|   uid  |  supplier   |
----------------------------
|    1   |  supplier1  |
----------------------------

COUNTRIES
---------------------------
|   uid  |  country   |
---------------------------
|    5   |  germany  |
---------------------------

Some customers and suppliers have offices in many countries, so is a
mm relationship.

I build a mm table that looks like this:
-----------------------------------------------------------------------------------
|   uid_local   |   uid_foreign   |   tablenames   |   sorting   |
-----------------------------------------------------------------------------------
|        1         |          5          |      suppliers    |       1
      |
-----------------------------------------------------------------------------------
|        1         |          5          |     customers   |       1       |
-----------------------------------------------------------------------------------
¿Is it correct?
I understand this:
The first row means that supplier1 is in germany.
The second row means that customer1 is also in germany.

But I already have doubts:
¿Is it necessary some TCA configuration in order to TYPO3 understand
the relations?
¿Is possible to setup it from Kickstarter?
¿Is necessary to set an index for the tablenames field?

Thanks in advance.

2011/6/16 Dmitry Dulepov <dmitry.dulepov at gmail.com>:
> Hi!
>
> Guillermo R. Oramas J. wrote:
>>
>> I noticed there is a field "tablenames" that is used in the mm tables.
>>
>> I looked for information but it appears that there is not much.
>>
>> I have two very similar tables that have a mm relation with a third
>> table, so I created two mm tables, but I guess that with this
>> "tablenames" is possible to have only one.
>>
>> Could someone guide me through the correct use of that field?
>
> That field is used when you can have a relation from one record type to many
> other record types in one field.
>
> For example, FE users has relation to FE groups. If we used MM relations
> there, it would be one record type and table names is not necessary.
>
> Now imagine you have a shop and user has a wishlist. Goods are in different
> tables depending on the good type. But the wish list must be able to
> reference any good. So you need table names in the MM table to know what
> good it is. If there were no table names, you would have to have a separate
> MM table for each good type, which is not good if you want to add a new type
> or do efficient selects.
>
> --
> Dmitry "itoldyou" Dulepov
> TYPO3 core&security team member
> E-mail: dmitry.dulepov at typo3.org
> Web: http://dmitry-dulepov.com/
>
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
>


More information about the TYPO3-english mailing list