TYPO3 Extension Builder Foreign Key

Why doesn't TYPO3 Extension Builder create foreign keys?

I have established some relationship between models, but the SQL Code has noe FKs only colums for the key value.

Can anyone help me?

+1


source to share


1 answer


Cite from Kartsen Dambekalns

This is a semi-conscious design decision. Just look at the date when the foreign key constraints that are being introduced into MySQL are compared to when TYPO3 was "born".

Of course, it would be great to add such links, especially since MySQL can always handle them even if the underlying storage engine does not handle them (in which case they will simply be ignored).

( source )

Nothing has changed so far, so you need to create foreign keys yourself after modeling.

Reply to comment:



how did you deal with the relationship between the two tables? for example i have a table that belongs to a dining house with a housenr column

It depends on the relationship of the course ( 1:n

, n:1

, m:n

etc.), as well Builder supports the establishment of relations in the modeling tool. Keep in mind that foreign keys are NOT required to maintain relationships in TYPO3.

There are some rules described in the TCA documentation section, that is, in the specified case, you can use select

or group (with internal_type)

. For a many-to-many relationship, you also need to create an MM table. If you follow these docs, you can be sure that the general form of backend editing will handle them properly.

As mentioned earlier, the Extension Builder supports the creation of different types of relationships in its click modeling tool, and it is worth spending some time playing with it to see how relationships of different types are handled in TYPO3. It uses the same rules that are used when creating relationships also in pre-extbase extensions. What else Builder adds the required methods to the models, i.e. For objects getting

, attaching

and detaching

MM of a given relationship field, it is therefore most important to model all your relationships at the beginning. Otherwise, you will need to write these methods manually (which is a boring process)

+3


source







All Articles