We've been using Phalcon for years and love it, however the database documentation has always been somewhat lacking. I've been looking closer at the current model relationships documentation and had a query about the following example. Putting aside the fact that the Parts model changes its schema part way through the examples, and it would be better to use examples that remain consistent throughout the documentation, the following snippet of a multiple fields scenario seems confusing and problematic.
$this->hasOne( ['id', 'type'], Parts::class, ['robotId', 'robotType'], [ 'reusable' => true, // cache related data 'alias' => 'parts', ] );
First, robotType is described as being "Mechanical etc." and I wonder what the etc. might mean in practice because could it really be anything else. Next, Robots id is unique, therefore the robot type for a given robot is unique. Why would the (now redefined) Parts model need a robotType field given that it has the robotId field? We can obtain the robotType for a part from the related robot record, and with a suitable index there would be no performance issue from the join to do that. Replicating the robotType between robot and parts is also problematic because should the type of a robot be changed, the parts would need to be updated too, so I don't understand the thinking behand this example.
Can someone explain the example better and say why it is like it is, why there is the duplicate robot type etc.