我有以下数据库关系:
Building hasMany Shape
Appartment hasOne Shape
Building hasMany Appartment
Shape belongsTo Building & Appartment
现在,在 Shape 模型中,我想检索属于某个建筑物的所有形状。这包括属于该特定建筑物的公寓的形状。
例如
Building 'X'
There are 4 shapes directly linked to building X via the belongsTo Building relation.
Shape->Building
And there are 2 shapes directly linked to 2 appartments via the belongsTo Appartment relation. These 2 appartments again are directly linked to Building X via the belongsTo Building relation. Thus these 2 shapes are indirectly linked to building X.
Shape->Appartment->Building
我似乎无法理解这一点,非常感谢您的帮助。