避免在中间存储数据时的 TYPO3 后端工作流程 table
TYPO3 backend workflow when avoiding the storage of data in intermediate table
我遇到了 ExtbaseFluid 书中描述的情况:
我想在中间存储信息 table 根本不推荐。
引用上述链接书籍章节的警告框:
Do not store data in the Intermediate Table that concern the Domain. Though TYPO3 supports this (especially in combination with Inline Relational Record Editing (IRRE) but this is always a sign that further improvements can be made to your Domain Model. Intermediate Tables are and should always be tools for storing relationships and nothing else.
Let’s say you want to store a CD with its containing music tracks: CD -- m:n (Intermediate Table) -- Song
. The track number may be stored in a field of the Intermediate Table. However, the track should be stored as a separate domain object, and the connection be realized as CD -- 1:n -- Track -- n:1 -- Song
.
所以我不想做不推荐的事情。但是考虑到推荐解决方案结果的编辑工作流程对我来说提出了一些问题。
为了继续这个例子,我需要以下 tables:
tx_extname_domain_model_cd
tx_extname_domain_model_cd_track_mm
tx_extname_domain_model_track (which holds the track number)
tx_extname_domain_model_track_song_mm
tx_extname_domain_model_song
据我所知,这将导致编辑需要创建以下记录的情况:
- 一条记录为
cd
- 一条记录为
song
- 现在编辑器可以为
track
创建一条记录。
那里添加了曲目编号。
此外,需要分配 cd
记录以及 song
.
所以这是我的问题:
- 我想这个工作流程不能通过一些(我不知道的)TCA 设置来改进?
- 打开
cd
记录时,编辑器无法直接到达 song
?
相反,首先她/他必须打开 track
记录,然后可以从那里导航到 song
?
- 中间存储数据真的有那么糟糕吗table? TYPO3 table
sys_file_reference
也一样!?但我想知道如何显示这些数据(因为 IRRE 是不可能的,因为它只能用于 1:n
关系(source)。
取决于问题,有时中间 table 是一个实体,有时不是。在此示例中,中间 table 是曲目,它将包含:[uid、cd、歌曲、track_no、...(定义曲目所需的任何其他内容)]
定义数据时要小心,不要让它太高级。
您必须问自己的问题是:我是想按照书本进行编码,还是想创建一种务实的方法来解决客户的问题?
在这个具体案例中,额外的问题是,最初发明 Extbase 的人有一个相当复杂和学术的方法,但是当涉及到实用的使用和性能时,他们被他们自己的规则所阻碍并坚持使用按书编码。
特别是这个例子和警告消息显示了一种思维方式,这是 我从未真正使用过 Extbase 而选择 Core-API 的原因之一创建高性能和实用查询以获得所需结果集的方法。现在我们已经了解了 Doctrine
,即使是非常奇特的 DB 风格,这也很有魅力。
当然 intermediate tables
是个好主意,当然那些 intermediate tables
可以而且应该用额外的数据字段来丰富,不需要 第 3、4 或第 n 个 table 存储,即一组简单的下拉选项,因为这可以很容易地用 TCA
中配置的 attributes
处理,如下所示:https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Type/Inline/Examples.html
sys_file_reference
是最突出的例子,因为它提供了不应该被注入额外 tables 的那种额外信息——你猜怎么着,TYPO3 核心不使用一行 Extbase 代码来处理该数据 或核心 tables.
的几乎任何其他数据
回答您的最后一个问题:查看旧的 IRRE 教程,了解如何使用中间内联 table 进行 m:n 连接。
https://docs.typo3.org/typo3cms/extensions/irre_tutorial/0.4.0/Manual/Index.html#intermediate-tables-for-m-n-relations
我遇到了 ExtbaseFluid 书中描述的情况:
我想在中间存储信息 table 根本不推荐。
引用上述链接书籍章节的警告框:
Do not store data in the Intermediate Table that concern the Domain. Though TYPO3 supports this (especially in combination with Inline Relational Record Editing (IRRE) but this is always a sign that further improvements can be made to your Domain Model. Intermediate Tables are and should always be tools for storing relationships and nothing else.
Let’s say you want to store a CD with its containing music tracks:CD -- m:n (Intermediate Table) -- Song
. The track number may be stored in a field of the Intermediate Table. However, the track should be stored as a separate domain object, and the connection be realized asCD -- 1:n -- Track -- n:1 -- Song
.
所以我不想做不推荐的事情。但是考虑到推荐解决方案结果的编辑工作流程对我来说提出了一些问题。
为了继续这个例子,我需要以下 tables:
tx_extname_domain_model_cd
tx_extname_domain_model_cd_track_mm
tx_extname_domain_model_track (which holds the track number)
tx_extname_domain_model_track_song_mm
tx_extname_domain_model_song
据我所知,这将导致编辑需要创建以下记录的情况:
- 一条记录为
cd
- 一条记录为
song
- 现在编辑器可以为
track
创建一条记录。
那里添加了曲目编号。
此外,需要分配cd
记录以及song
.
所以这是我的问题:
- 我想这个工作流程不能通过一些(我不知道的)TCA 设置来改进?
- 打开
cd
记录时,编辑器无法直接到达song
?
相反,首先她/他必须打开track
记录,然后可以从那里导航到song
? - 中间存储数据真的有那么糟糕吗table? TYPO3 table
sys_file_reference
也一样!?但我想知道如何显示这些数据(因为 IRRE 是不可能的,因为它只能用于1:n
关系(source)。
取决于问题,有时中间 table 是一个实体,有时不是。在此示例中,中间 table 是曲目,它将包含:[uid、cd、歌曲、track_no、...(定义曲目所需的任何其他内容)]
定义数据时要小心,不要让它太高级。
您必须问自己的问题是:我是想按照书本进行编码,还是想创建一种务实的方法来解决客户的问题?
在这个具体案例中,额外的问题是,最初发明 Extbase 的人有一个相当复杂和学术的方法,但是当涉及到实用的使用和性能时,他们被他们自己的规则所阻碍并坚持使用按书编码。
特别是这个例子和警告消息显示了一种思维方式,这是 我从未真正使用过 Extbase 而选择 Core-API 的原因之一创建高性能和实用查询以获得所需结果集的方法。现在我们已经了解了 Doctrine
,即使是非常奇特的 DB 风格,这也很有魅力。
当然 intermediate tables
是个好主意,当然那些 intermediate tables
可以而且应该用额外的数据字段来丰富,不需要 第 3、4 或第 n 个 table 存储,即一组简单的下拉选项,因为这可以很容易地用 TCA
中配置的 attributes
处理,如下所示:https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Type/Inline/Examples.html
sys_file_reference
是最突出的例子,因为它提供了不应该被注入额外 tables 的那种额外信息——你猜怎么着,TYPO3 核心不使用一行 Extbase 代码来处理该数据 或核心 tables.
回答您的最后一个问题:查看旧的 IRRE 教程,了解如何使用中间内联 table 进行 m:n 连接。 https://docs.typo3.org/typo3cms/extensions/irre_tutorial/0.4.0/Manual/Index.html#intermediate-tables-for-m-n-relations